The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #11 (permalink)  
Old 06-23-2009
durden_tyler's Avatar
durden_tyler durden_tyler is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 523
Quote:
Originally Posted by pa.chidhambaram View Post
...
You can use the below command to delete the invalid line.

cat data | awk '{ if(substr($1,1,5)!="" && substr($1,6,10)!="" && substr($1,11,12)!="") print $1}' > new_filtered_file_name.

Where the data is the input file.

...
Really ?

Code:
$
$ cat data
DINESKUMAR21
SACHISHAH 23
          23
GURUNTARIM22
$
$ cat data | awk '{ if(substr($1,1,5)!="" && substr($1,6,10)!="" && substr($1,11,12)!="") print $1}'
DINESKUMAR21
GURUNTARIM22
$
$
tyler_durden