Tuesday, January 8, 2013

CAT FILE WITH EXCEPTION ROW ON SOLARIS

Sometimes, you need to view content of a file with exception some row.
For example, you have file named test.txt which content like below :

1111
2222
3333
4444
#5555
#6666

You want :
(1) Display all row except first row
(2) Display all row except row which have sign "#"

What command that you can use ?

(1) cat test.txt | grep -v "1"  or 
      cat test.txt | grep -v "11"  or 
      cat test.txt | grep -v "111" or 
      cat test.txt | grep -v "1111"

(2) cat test.txt | grep -v "#"  

Hopefully it will help you :)  

No comments:

Post a Comment