The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to serach if a new line character exists on the last line in a file sunilbm78 UNIX for Dummies Questions & Answers 10 02-29-2008 11:15 AM
Sort a file line by line alphabetically H2OBoodle Shell Programming and Scripting 11 02-11-2008 04:27 AM
Identify duplicate words in a line using command srinivasan_85 UNIX for Dummies Questions & Answers 8 04-30-2007 10:29 PM
Appending the line number and a seperator to each line of a file ? pjcwhite Shell Programming and Scripting 4 03-20-2007 10:29 PM
Remove header(first line) and trailer(last line) in ANY given file madhunk Shell Programming and Scripting 2 03-13-2006 12:36 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-01-2007
Registered User
 

Join Date: Jul 2004
Location: PUNE
Posts: 5
Need to identify the line containing @ in between the line of a file

Hi All,

I have a huge unix flat file delimted by @ at the end of the line. I need to find out if there is any line/s containing @ in between the line so that I can remove that and put the file for processing.

Thanks in advance for your help.
Reply With Quote
Forum Sponsor
  #2  
Old 11-01-2007
Registered User
 

Join Date: Nov 2007
Location: Sydney, Australia
Posts: 5
Unclear - please give more info

Hi
I'm not quite clear on your post.
Are all lines terminated with an @?
What do you mean 'in between the line'?
Can you give (an abbreviated) example of what you are trying to do?
Peter
Reply With Quote
  #3  
Old 11-02-2007
Registered User
 

Join Date: Jul 2004
Location: PUNE
Posts: 5
Hi peter,

The few lines from example file look like;

0000000014471;S;00;05; ;-0038044;000000000;000000000;01112007; @
0000000015630;S;00;12;CSH;-0007017;000000000;000000000;01112007; @
0000000075945;S;00;25;ETO;00038227;000038227;000000000;01112007; @

All lines are are terminated with delimiter '@'. Sometimes within the line we get @ thereby creating a mismatch between the records in the file and records in the trailer (File count > Trailer Count). For example;

5000006267 ;U;DR &; ;HARPER @ ;2 MARITIME ;24062002;+000023772; ;000000;00000000;23102007;+000000000;2306
2002;+000023772;D;11; ; ; ;0000; ;COT;06111998;00@

here after HARPER there is a '@' which creates count mismatch.

We usually use a macro to identify the extra delimiter within the line and delete it manually and then run a validation script to see if it passes the record count validation .

I need to find out two scenarios;

1. Lines containing '@' within
2. Lines missing '@' at the end of line

Regards,
Bhausab
Reply With Quote
  #4  
Old 11-02-2007
Registered User
 

Join Date: Oct 2004
Posts: 235
there may be a lot of way , Just an idea .. Remove all @ by using sed , and the insert @ at every endof line ...

PLease let me know if you need the sed commands
Reply With Quote
  #5  
Old 11-04-2007
Registered User
 

Join Date: Nov 2007
Location: Sydney, Australia
Posts: 5
Answer: use egrep

1. Lines containing '@' within
This is easy if you use egrep:

$ cat file.txt | egrep '@.+'

2. Lines missing '@' at the end of line
Use -v to get those lines that don't match:

$ cat file.txt | grep -v '@$'


Peter
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0