parsing a delimited line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parsing a delimited line
# 8  
Old 07-12-2006
Monkeys wrote:
> What I want to do is find the token starting with "C", and print it and its value > (so I'd want to print "C=3" in the example above).

So I guess it works !
# 9  
Old 07-12-2006
Quote:
Originally Posted by sajithn
Monkeys wrote:
> What I want to do is find the token starting with "C", and print it and its value > (so I'd want to print "C=3" in the example above).

So I guess it works !
Doesn't the 'token' "CAB" start with 'C'?
# 10  
Old 07-12-2006
Quote:
Originally Posted by Ygor
Try...
Code:
awk 'BEGIN{FS="=";RS="|"}$1=="C"{print $2}'

or if any token that starts with C (eg CAB like vgersh99) is suggesting:

Code:
awk 'BEGIN{FS="=";RS="|"}/^C/ {print $2}'

# 11  
Old 07-12-2006
Quote:
Originally Posted by reborg
or if any token that starts with C (eg CAB like vgersh99) is suggesting:

Code:
awk 'BEGIN{FS="=";RS="|"}/^C/ {print $2}'

Actually.... the OPs description:

Quote:
Originally Posted by monkeys
What I want to do is find the token starting with "C", and print it and its value (so I'd want to print "C=3" in the example above).
could be interpreted 2 different ways.
  1. C=1
  2. CAB=1

My interpretation was '1', but I might be wrong......
Let the OP decide.......

Last edited by vgersh99; 07-12-2006 at 10:12 PM..
# 12  
Old 07-12-2006
yep, got that, I was offering a 2 if that was what the OP wanted since you had already pointed out the strictness/loseness of the solutions proposed.

Sometimes I should be a bit more verbose Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add the line to previous line in | delimited text?

Hi All, I am new to Unix and I have one challenge and below are the details. I have pipe delimited text file in that data has span into multiple lines instead of single line. Sample data. Data should be like below for entire file. 41|216|398555|77|provided complete NP outcome data ... (21 Replies)
Discussion started by: Narasimhasss
21 Replies

2. Shell Programming and Scripting

Replace ^M and the new line that follows it in a delimited file

Hello, I want to Replace/Remove ^M and the new line that follows it in a delimited file. So far I have tried following and nothing seems to work for me . Tr –d ‘\r\n’ < old.dat > new.dat -removes all the linefeed, not just the ones after a ^M. Sed ‘/^M$/{N; s/.\n//;}’ < old.dat >... (7 Replies)
Discussion started by: bluestarmoon
7 Replies

3. Shell Programming and Scripting

How can i comma-delimited last field in line?

Awk gurus, Greatly appreciate for any kind of assistance from the expert community Input line: abc,11.22.33.44,xyz,7-8-9-10 pqr,111.222.333.444,wxy,1-2-3 def,22.33.44.55,stu,7-8 used the gsub function below but it changes all of the "-" delimiter: awk 'gsub("-",",")' Desired... (4 Replies)
Discussion started by: ux4me
4 Replies

4. UNIX for Dummies Questions & Answers

Parsing file, reading each line to variable, evaluating date/time stamp of each line

So, the beginning of my script will cat & grep a file with the output directed to a new file. The data I have in this file needs to be parsed, read and evaluated. Basically, I need to identify the latest date/time stamp and then calculate whether or not it is within 15 minutes of the current... (1 Reply)
Discussion started by: hynesward
1 Replies

5. Shell Programming and Scripting

Convert Rows to Space Delimited Line

Hello, I would like to convert a list of rows to a space separated line. Any ideas? Input file: "Administration Tools" "Design Suite" "Dial-up Networking Support" "Editors" desired output "Administration Tools" "Design Suite" "Dial-up Networking Support" "Editors" Thanks,... (4 Replies)
Discussion started by: jaysunn
4 Replies

6. Shell Programming and Scripting

Parsing delimited file

I'll have a file with ever changing lengths depending on the report. Right now it is stored by : delimiter. My question is how do I parse through this b/c it will be changing lengths each time. Example: 1:2:3:4:5 1:2:3:4:5:6:7:8:9 1:2:3 I want to take each one and place in newline for... (5 Replies)
Discussion started by: mhuffs90171
5 Replies

7. Red Hat

help with parsing through delimited file

I need to parse through the following file and extract the BIG02 field. ISA*00* *00* *01*069737914 *01*044760643 ... (1 Reply)
Discussion started by: bds052189
1 Replies

8. Shell Programming and Scripting

4 GB delimited-textfile on ONE LINE

I have delimited-text files ( > 4GB ) and is just one line. OS: HP-UX 11.23 Awk / cut / sed all have line_max limitations. & unable to read one line in (Buffered-mode). Sample file: xxxx|adsfadf|Afdsa|adsf|afds|Asdfas|ads|Afds|Asdf| .....till forever, I want to put a carriage... (5 Replies)
Discussion started by: magedfawzy
5 Replies

9. Shell Programming and Scripting

Perl question, parsing line by line

Hello, Im very new to PERL and as a project to work on developing my skills at PERL Im trying to parse poker hands. Ive tried many methods however I cant get the last step. $yourfile= 'FILENAME';#poker hands to parse open (FILE, "$yourfile") or die $!; @lines = <FILE>; for (@lines) ... (1 Reply)
Discussion started by: Ek0
1 Replies

10. Shell Programming and Scripting

Parsing comma delimited text file

I need to delete a set of files in certain directories if there're older than a certain number of days. So I have a text file, with each line containing the directory & number of days. The format is like this: dirA,5 dirB,7 How do I write script to iteratively parse this text file & delete... (5 Replies)
Discussion started by: chengwei
5 Replies
Login or Register to Ask a Question