JAVA SCRIPT

RH033 7. TEXT PROCESSING TOOLS IN LINUX




1. head  <file name>   = shows first ten lines of file by text.

   head -n <file name> =Shows first n num of lines   //where n is num


2.tail    <file name>   =Shows last ten lines of file by default

  tail -n <file name>   =Shows last n num of lines   //where n is num


3. <file> |less  =Opens file from first page

   n =next
   N=Previous
   gg=Beginning page of file
   G=End of file
   q=quit


4. cut -d: -f1 <file>             
//cut and display first field of file,where    d->delimeter f->field
                              
   cut -d: -f1,3 <file>           //First and 3 field of file

   cut -d: -f1-3 <file>          //First to 3 field of file


5. sed 's/abc/xyz/g'  <file> 
 //Edit word abc with word xyz in file  
  s-> substitute  g->globally
                             

 sed -i 's/abc/xyz/g'  <file> /Edit permanently in file                                                
   sed '1p' <file>        //Print first line twice                                                                 

   sed '1d' <file>           //Delete first line                                                               
    sed -e 's/abc/xyz/g'  -e 's/123/456/g' <file>   
      //Edit 2 words at a time


6. grep    keyword <file>             
 Search keyword and display lines having keyword

 grep -v keyword <file>                     
Search keyword and display lines NOT having keyword\

 grep -c keyword <file>    
Count num of words having keyword

grep -l keyword <file1> <file2>   
Search  keyword in 2 files and display    file tht contain keyword.                       

grep -L keyword <file1> <file2>  
File tht does-not contain keyword.


7.  sort    <file>   =Sort file
    sort -r <file>       =Sort file in reverse order


8.  uniq -u <file>    =Print uniq words in file
    uniq -d <file>      =Print repeated words in file
    uniq -c <file>      =Print num of lines having word repeated


 

No comments:

Post a Comment