Categories
status

Display file contents with file names tail +1…

Display file contents with file names;

tail +1 many_files*

It works on Mac, BSD.

For GNU tail, use

tail -n +1 many_files*

Update: GNU tail has different parameters.

http://stackoverflow.com/questions/5917413/cat-multiple-files-but-include-filename-as-headers

Categories
status

Viewing huge text files between specific lines $…

Viewing huge text files; between specific lines

$ sed -n 101,110p /var/log/cron

10 Awesome Examples for Viewing Huge Log Files in Unix

Categories
status

Nice tips of unix command tools 123 398…

Nice tips of unix command tools

123   398  17359
317    19    2909
 39  -399   -5789
 49    33      200
255   33     -378
sort -n file 

Sort the file by first column. The -n option ensures numeric (as opposed to lexicographic) sort.

sort -k 2 -n file 

Sort the file by second column. The “-k” option here denotes the column used as sort key.

grep '33' file 

Extract all lines containing the string “33” (in the above example, lines 4 and 5).

grep -c '33' file 

Same, but display only the number of matching lines (2 in the example), not the lines themselves. This is useful to analyze large data files of output data. For example, if a sequence of one million integers, is saved as a file, one per line, “grep -c ’33’ file” will display the number of 0’s in that sequence.

grep -c '-' *.out 

Same command, but applied to all files in the current directory matching “*.out”. For each file there is an output line of the form “Filename: x”, where “x” is the number of matching lines in the file.

sort -n file | cat -n 

Sort the file, then prepend line numbers to each line. This results in the following:

     1	 39  -399  -5789
     2	 49  33   200
     3	123  398  17359
     4	255 33   -378
     5	317  19  2909

http://www.math.uiuc.edu/~hildebr/computer/unixtips.html

Categories
status

Remove all files but one rm f one…

Remove all files but one.

rm -f !(one.txt)

http://www.commandlinefu.com/commands/view/6652/remove-all-but-one-specific-file

Categories
status

LaTeX document spelling checker in Linux …

LaTeX document spelling checker in Linux
aspell check –mode=tex

Categories
status

When the forward search of readline is n …

When the forward search of readline is not working.

$ stty -a
$ stty -ixon

Categories
status

Quick fix of command line typo ^type^ …

Quick fix of command line typo

^typo^correct

This will replace the word ‘typo’ with ‘correct’ from the previous command line.
http://lifehacker.com/5698494/quickly-fix-command-line-mistakes-with-the–symbol