1. To convert dos2unix and unix2dos commands.
dos to unix:
sed 's/\r$//' dos.txt > unix.txt
unix to dos:
sed 's/$/\r/' unix.txt > dos.txt
2. To trim the string at both ends.sed 's/\r$//' dos.txt > unix.txt
unix to dos:
sed 's/$/\r/' unix.txt > dos.txt
echo " abcd abcd " | xarge
Ouput: <No spaces>abcd abcd<no spaces>
3. How to find files having a string from set of files
find . -name "*.xml" -exec grep -il "33960750" {} \;
4. To show first 10 lines in a file
head -10 filename.txt
5. To show last 10 lines in a file.
tail -10 filename.txt
6. To know differences between two files
diff filesname1.txt filename2.txt
7. To sort a file with eliminating duplicates.
sort -u filename.txt
8. find and printing file names only
find . -name "*samp*.txt" -print
No comments:
Post a Comment