UNIX Commands for ETL Developer/ Tester/ Support
- LIST
1) Unix command to list files in descending order
ls -ltr
2) Unix command to list files based on file size
ls -ls
ls -la | grep ^[.]
- KILL
1) UNIX command to kill background jobs
KILL $!
- PRINT
1) UNIX command to print the first line of the file
HEAD -1 filename.txt
or
SED '2$' filename.txt
TAIL -1 filename.txt
or
SED -n '$p' filename.txt
3) UNIX command to print an Nth line of the file
SED -n '<n> $p' filename.txt
<n> - number of line
4) UNIX command to print a word in reverse
echo
| rev
echo 'C for Car' | rev | CUT -f 1 d ' ' | rev
- REMOVE
SED '1d' filename.txt
2) UNIX command to remove the last line of the file
SED -i '$d' filename.txt
3) UNIX command to remove Nth line of the file
SED -i '<n> $d' filename.txt
<n> - number of line
GREP -v ^"$" filename.txt
CUT -f <n> -d ' '
<n> - number of line
- COUNT
filename.txt | wc -l
2) UNIX command to find the length of the Nth line in the file
SED -n '<n> p' filename.txt | wc -L
<n> - number of line
- OTHERS
vi filename.txt
In vi mode you can view the non-printable words in the file
2) Remove BOM characters
SED -i '1s/^\xEF\xBB\xBF//' filename.txt
No comments:
Post a Comment