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 02:15 PM
Sort a file line by line alphabetically H2OBoodle Shell Programming and Scripting 11 02-11-2008 07:27 AM
Identify duplicate words in a line using command srinivasan_85 UNIX for Dummies Questions & Answers 8 05-01-2007 02:29 AM
Appending the line number and a seperator to each line of a file ? pjcwhite Shell Programming and Scripting 4 03-21-2007 01:29 AM
Remove header(first line) and trailer(last line) in ANY given file madhunk Shell Programming and Scripting 2 03-13-2006 03:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-01-2007
b.paramanatti b.paramanatti is offline
Registered User
  
 

Join Date: Jul 2004
Location: PUNE
Posts: 10
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 (permalink)  
Old 11-01-2007
peterl peterl is offline
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
  #3 (permalink)  
Old 11-02-2007
b.paramanatti b.paramanatti is offline
Registered User
  
 

Join Date: Jul 2004
Location: PUNE
Posts: 10
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 (permalink)  
Old 11-02-2007
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
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 (permalink)  
Old 11-04-2007
peterl peterl is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0