![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 10:15 AM |
| Sort a file line by line alphabetically | H2OBoodle | Shell Programming and Scripting | 11 | 02-11-2008 03: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 09:29 PM |
| Remove header(first line) and trailer(last line) in ANY given file | madhunk | Shell Programming and Scripting | 2 | 03-13-2006 11:36 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |