Computing Tips
for
Linux/UNIX Computers


back to main page

Table of Contents



Topics

Survival Skills for UNIX-like Systems

This was from a UNIX tutorial talk back in March 2011, intending for beginners of UNIX-like system users. The full length of the talk title was: "Survival Skills for Analytical Processing of Data of Statistical Genetics Research in UNIX-like Systems". It seems to be a little awkward but it was requested to give to the new users in that area. However, there is a cheatsheet of UNIX/LINUX commands, which may serve a quick reference in your starting using UNIX/LINUX.

Here is the slides link: UNIX/LINUX Survival Skills

Quick transpose a single line

How to quickly transpose a single line (from horizonal to vertical, or vice versa) can be very useful. For example, we have a large data set with the first row containing the sample IDs. We want to quickly know how many IDs there are and how they are ordered.

At commandline, type "tr ',' '\n' < input.txt > output.txt", where the input.txt file contains the single line of text delimited by comma ",". And the output.txt file will list the line into one column.

input.txt:

12,a,b
	

output.txt:

12
a
b
	

If there are more than one line, then this transpose command will transpose all lines into one single column.

If you type "tr '\n' ',' < output.txt > output2.txt", then it will transpose one column into one row. This is basically transposing multilines into one single one.

output.txt:

12,a,b
w x  y
y = 9 + Ax
	

output2.txt:

12,a,b,w x  y,y = 9 + Ax
	

This command takes multiple delimiters, e.g. both "," and "\t", as this way "tr ',\t' '\n' < input.txt > output.txt".

Measuring Your Directories

tbf


Contact for web content questions: Robert Yu via rkyu@mdanderson.org