Posts Tagged With: line

Remove Empty Characters at End of Lines

Tagged with: , , , ,

Remove empty characters at the end of each row


sed -e 's/ *$//' file.txt
No Comments »

First Two Lines

Tagged with: , , , ,

View first two lines of a file


head -2 file

tail -2 file # for last 2 lines
No Comments »

Remove Empty Lines

Tagged with: , , , , , , ,

Remove empty lines from a file using sed


sed '/^$/d' file.txt

Original Article

No Comments »

Double Space a File using Sed

Tagged with: , , , , , , ,

Add a \n after every line in a file using the sed command…


sed G 
No Comments »

Get the First Line of Command Output in Shell

Tagged with: , , , , ,

Get just the first line of the output of a command…


<command>|head -n1

ls -1|head -n1
No Comments »

Replace \n with another String

Tagged with: , , , ,

The command to convert all \n in a file to another string – very useful for list code generation.


perl -ne 's/\\n/\',\'/g;print;' file.txt>new.txt
1 Comment »