how to parse the content


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to parse the content
# 1  
Old 12-04-2008
how to parse the content

How the below ex.txt file can be parsed using starting bracket'(' and ending bracket')' and hav to store the values without quotes in a text file.

There will be some 10 or 20 lines inbetween starting brakcet and ending bracket at first there may be 5 words,2ndl ine only 1 word, third line 6 words and 4th line 2 words. so words ineach line will differ...so by keeping brackets as start'(' and end ')' i want to store all the words in some 2 or 3 lines with comma separated

ex.txt
-----------------------------------
('name','time'...
'value1',vlaue2',value3'...
'value10','value11',value12')
-----------------------------------

can any one say the command to achive the above using awk? or any
# 2  
Old 12-05-2008
Quote:
i want to store all the words in some 2 or 3 lines
Be more precise. Also post the desire output. If it is just for getting rid of the single quotes, take this as a start
Code:
tr -d "'" < ex.txt

# 3  
Old 12-05-2008
this sed command also remove the single quote
Code:
sed s/\'//g input_file

# 4  
Old 12-05-2008
awk 'BEGIN {started=0} { if (substr($0,1,1)=="(") {
started=1; print substr($0,2); next;
}
else if (started==0){
next
} if (substr($0,length($0),1)==")") { started=0; print substr($0,1,length($0)-1); next; } print $0
}' input_file | tr "'" "\0"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse

Attached file is parsed so that only the three columns result. DACH1 occurs 34 times with an average of 0.881541 NEB occurs 159 times with an average of 0.837628 LTBP1 occurs 46 times with an average of 0.748722 parse result: output.txt (the text is removed and the xxx is seperated in a... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

3. Shell Programming and Scripting

Facing issues with Content-Type:application/x-download Content-Disposition:attachment

I am in the process of developing a perl cgi page. I had succeeded in developing the page but there are few errors/issues with the page. description about cgi page: My CGI page retrieves all the file names from an directory and displays the files in drop down menu for downloading the... (5 Replies)
Discussion started by: scriptscript
5 Replies

4. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

5. Shell Programming and Scripting

Help with remove duplicate content and only keep the first content detail

Input data_10 SSA data_2 TYUE data_3 PEOCV data_6 SSAT data_21 SSA data_19 TYUEC data_14 TYUE data_15 SSA data_32 PEOCV . . Desired Output data_10 SSA data_2 TYUE data_3 PEOCV data_6 SSAT data_19 TYUEC (9 Replies)
Discussion started by: patrick87
9 Replies

6. Shell Programming and Scripting

sed, awk [TAG]$content[/TAG] How to get var in $content in textfile?

Hello, I got a Qstion. Im posting to a phpbb forum with bash and curl.. i have a text file with the following tags that i post to the forum: $var1 $var2 $var3 How can i with sed or awk put var content from shell script between the ... in the... (7 Replies)
Discussion started by: atmosroll
7 Replies

7. Shell Programming and Scripting

How to read and parse the content of csv file containing # as delimeter into fields using Bash?

#!/bin/bash i=0 cat 1.csv | while read fileline do echo "$fileline" IFS="#" flds=( $fileline ) nrofflds=${#flds} echo "noof fields$nrofflds" fld=0 while do echo "noof counter$fld" echo "$nrofflds" #fld1="${flds}" trying to store the content of line to fields but i... (4 Replies)
Discussion started by: barani75
4 Replies

8. Shell Programming and Scripting

how to delete content in a file (delete content only)

Hi Friends I have a file called processLog.txt file processLog.txt --------------- echo "line starts "$LINE suppCode=${LINE:0:3} #gatewayArchive=`scp root@mrp-gateway:/usr/local/apache/data/PLAT/MIMUS/upload/PROD/archive/112042708173000.txt /home/krishnaveni/scripts/tempFolder` #echo... (5 Replies)
Discussion started by: kittusri9
5 Replies

9. Shell Programming and Scripting

Content of Content of a variable!

I got a sample BASH script like this : $ cat test MYVAR=$1 DUMMY1="This is tricky" DUMMY2=24 echo $ $ ./test DUMMY1 ./test: line 5: This is tricky: syntax error in expression (error token is "is tricky") **I was expecting the output as "This is tricky", ah! but no luck **But... (2 Replies)
Discussion started by: jaduks
2 Replies

10. Shell Programming and Scripting

How to parse..

Help, I need to get the port number of a Oracle database using the tnsping command. I need to parse it's output. ===================== Attempting to contact (ADDRESS=(PROTOCOL=TCP)(Host=chamar)(Port=1541)) Sometimes may be like this: Attempting to contact... (8 Replies)
Discussion started by: natter
8 Replies
Login or Register to Ask a Question