Text type convert
Tagged with: command, dos, dos2unix, eol, line, Linux, text, unix
Saturday, June 21st, 2008 11:00 PM
Convert a text file format from MSDOS to UNIX
dos2unix input_file output_file
Convert a text file format from MSDOS to UNIX
dos2unix input_file output_file
Sort contents of two files by viewing only duplicate line
sort file1 file2 | uniq -d
Sort contents of a file and remove repeated lines
sort file.txt | uniq
This command removes all the even lines from the file given as the argument
cat example.txt|awk 'NR%2==1'
View from 1th to 5th line
sed -n '1,5p;5q' example.txt
Remove empty characters at the end of each row
sed -e 's/ *$//' file.txt
View first two lines of a file
head -2 file
tail -2 file # for last 2 lines
Add a \n after every line in a file using the sed command…
sed G
Get just the first line of the output of a command…
<command>|head -n1
ls -1|head -n1
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