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 -->
  #10 (permalink)  
Old 06-23-2009
pa.chidhambaram pa.chidhambaram is offline
Registered User
  
 

Join Date: Feb 2008
Location: Nagercoil
Posts: 10
Quote:
Originally Posted by dinesh1985 View Post
input file
First Name - position from 1-5
Last Name- position 6-10
Age-Position 11-12
Say above is the format of input file.
Example:
DINESKUMAR21
SACHISHAH 23
23
GURUNTARIM22

In the above example,in the 3 rd record Name is missing. Now while reading the file line by line,I want to delete the 3 rd line during validation.

---------- Post updated at 08:47 AM ---------- Previous update was at 08:46 AM ----------

for the third line blankspaces will be present before 23
Hi,
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.

Thanks,
chidhu