Need to identify the line containing @ in between the line of a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to identify the line containing @ in between the line of a file
# 1  
Old 11-01-2007
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.
# 2  
Old 11-01-2007
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
# 3  
Old 11-02-2007
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
# 4  
Old 11-02-2007
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
# 5  
Old 11-04-2007
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

3. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

4. Shell Programming and Scripting

Regex to identify word in second position on a line

I am interested in finding a regex to find a word in second position on a line. The word in question is या I tried the following PERL EXPRESSION but it did not work: ] या or ^\W या But both gave Null results I am giving below a Sample file: देना या सौंपना=delegate तह जमना या... (8 Replies)
Discussion started by: gimley
8 Replies

5. Shell Programming and Scripting

Read file line by line and process the line to generate another file

Hi, i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here) i need to read this file line by line and generate an output file like the one below i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies

6. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

7. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies

8. Shell Programming and Scripting

Identify matching data in a file and output to original line, in perl

Hi, I haven't done this for awhile, and further, I've never done it in perl so I appreciate any help you can give me. I have a file of lines, each with 5 data points that look like this: AB,N,ALLIANCEBERNSTEIN HLDNG L.P,AB,N ALD,N,ALLIED CAPITAL CORPORATION,ALD,N AFC,N,ALLIED CAPITAL... (4 Replies)
Discussion started by: Pcushing
4 Replies

9. UNIX for Dummies Questions & Answers

Identify duplicate words in a line using command

Hi, Let me explain the problem clearly: Let the entries in my file be: lion,tiger,bear apple,mango,orange,apple,grape unix,windows,solaris,windows,linux red,blue,green,yellow orange,maroon,pink,violet,orange,pink Can we detect the lines in which one of the words(separated by field... (8 Replies)
Discussion started by: srinivasan_85
8 Replies
Login or Register to Ask a Question