1. Display 5th line of a file.
cat <file> | head -5 | tail -1
2. How to reverse a string in unix?
echo "reverse this string!" | rev
3. How to select last word of a line?
echo "i need the last word" | rev | cut -f1 -d' ' | rev
4. Select nth value from a comma seperated line.
echo "a,b,c d,e,f,g ,h"| cut -f<n> -d','
5. How to insert a header record to a file.
sed -i "1i HEADERTEXT" <outputfile>
Comments
Post a Comment