SilverWav's Journal

The best is yet to come…

Posts Tagged ‘awk

Note: Remove Duplicates from .bash_history

leave a comment »

awk '!x[$0]++' .bash_history > .bash.tmp && mv -f .bash.tmp .bash_history

Bug #189881

Advertisements

Written by SilverWav

April 17, 2010 at 12:49 pm

Posted in Notes

Tagged with , , , ,

Note: Remove First Column

leave a comment »

Remove first column of a space delimited text file.

cut -d\  -f2- file.txt > file_cut.txt

Cut is better than awk for this job, as you can see from the example below.

awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "$10" "$11" "$12"}' file.txt

Cut Details:
-d, –delimiter (using SPACE instead of TAB for field delimiter)
-f, –fields (select only these fields (-f2- parses as field2 to end of line).

Written by SilverWav

April 12, 2010 at 8:32 pm

Posted in Notes

Tagged with , , , ,