Tag: line
Iterate a Text File in Bash
May 25, 2012
This is how you iterate thru a text file outputting a line at a time in Bash shell scripting.
Add Line Numbers
July 7, 2009
Use this command to add line numbers to a text file… sed = filename.txt | sed ‘N;s/\n/\t/’ > filename_number.txt
Delete Leading Whitespace
May 11, 2009
Delete leading whitespace (spaces/tabs/etc) from beginning of each line ruby -pe ‘gsub(/^\s+/, “”)’ < file.txt
Sort by Line Length
April 14, 2009
Sort file by line length. Original Article… cat /etc/passwd | awk ‘{print length, 0}’ | sort -n | awk ‘{1=””;…
Text type convert
June 21, 2008
Convert a text file format from MSDOS to UNIX dos2unix input_file output_file
Find Duplicate Lines
May 21, 2008
Sort contents of two files by viewing only duplicate line sort file1 file2 | uniq -d
Remove Even Lines
April 27, 2008
This command removes all the even lines from the file given as the argument cat example.txt|awk ‘NR%2==1’
Recent Comments