sed data extract


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed data extract
# 1  
Old 11-10-2012
sed data extract

Hello,

I have huge number files in a directory. All files have the data. I want extract data. I want all output write to single csv file.
following codes works. Thank you very much for help.

Code:
sed -n '/.*Content$txtE_Zip" type="text" value="\([^<][^<]*\)" maxlength.*/s//\1/p' *>file1
sed -n '/.*Content$txtE_City" type="text" value="\([^<][^<]*\)" maxlength.*/s//\1/p' *>file2
sed -n '/.*Content$txtE_Address" type="text" value="\([^<][^<]*\)" maxlength.*/s//\1/p' *>file3
sed -n '/.*Content_lblPhone">\([^<][^<]*\)<\/span>.*/s//\1/p' *>file4
sed -n '/.*Content$txtE_State" type="text" value="\([^<][^<]*\)" maxlength.*/s//\1/p' *>file5
sed -n '/.*Content_lblBus">\([^<][^<]*\)<\/span>.*/s//\1/p' *>file6

I want single csv output. I want to make a sed operation.

output:
Code:
"file6","file5","file3 file2, file5 file1, USA","file4"


Last edited by Scott; 11-12-2012 at 04:12 AM.. Reason: ICODE tags -> CODE tags
# 2  
Old 11-10-2012
Use temporary files just like you are doing, and then paste them together:
Code:
paste -d, file[1-6]

Doing this with sed alone would be very difficult.
# 3  
Old 11-10-2012
I understand thanks. but i have a problem in phone data..

If there has not the data in source "Sed " write output file "no data" is this possible?

thank you very much.
# 4  
Old 11-11-2012
To identify which file is missing the string, I'd process them in a loop:
Code:
for i in inputs*.txt ; do 
   if grep -q "$string" ; then
       sed '...' $i
   else
        echo file $i is missing $string >&2
   fi
done

# 5  
Old 11-11-2012
Great, thank you Smilie
# 6  
Old 11-12-2012
Quote:
Originally Posted by hoo
. . .
I want single csv output. I want to make a sed operation.
Why don't you append all output to one single file using >> redirection?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract header data from one file and combine it with data from another file

Hi, Great minds, I have some files, in fact header files, of CTD profiler, I tried a lot C programming, could not get output as I was expected, because my programming skills are very poor, finally, joined unix forum with the hope that, I may get what I want, from you people, Here I have attached... (17 Replies)
Discussion started by: nex_asp
17 Replies

2. Shell Programming and Scripting

sed or awk, cut, to extract specific data from line

Hi guys, I have been trying to do this, but... no luck so maybe you can help me. I have a line like this: Total Handled, Received, on queue Input Mgs: 140 / 14 => 0 I need to, get the number after the / until the =, to get only 14 . Any help is greatly appreciated. Thanks, (4 Replies)
Discussion started by: ocramas
4 Replies

3. Shell Programming and Scripting

Router ping log extract data from it Awk/Sed/grep

Hi, I am new to this world.. Using expect i loging to router and checking ping response to my links. I need to genarate report using this output and that report contains only three file link name, packet loss, latency. my output of script is like below: -bash-3.00$ monmw/mwbkp... (2 Replies)
Discussion started by: jkmistry
2 Replies

4. Shell Programming and Scripting

Extract data b/w two words using sed

Hi, I want to extract data b/w two words with the help of sed.. Eg: In "Anna said that she would fetch the bucket", I want to display data b/w "Anna" and "would" O/P: said that she I have tried with below code, but unable to get desired o/p echo "Anna said that she would fetch the... (5 Replies)
Discussion started by: divya bandipotu
5 Replies

5. Shell Programming and Scripting

SED to extract HTML text data, not quite right!

I am attempting to extract weather data from the following website, but for the Victoria area only: Text Forecasts - Environment Canada I use this: sed -n "/Greater Victoria./,/Fraser Valley./p" But that phrasing does not sometimes get it all and think perhaps the website has more... (2 Replies)
Discussion started by: lagagnon
2 Replies

6. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

7. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

8. Shell Programming and Scripting

how to extract the data ?

Hi, I'm trying to pick out a data field eg. from below. I need the required field as below but they are filled sometimes with weird chars like \-(. or watever. How can I accurately extract the 3rd field in shell? :confused: ID IDNO - REQUIRED FIELD ID 1447 - MAT620BR. ID 1452 -... (13 Replies)
Discussion started by: uxnoob
13 Replies

9. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

10. Shell Programming and Scripting

sed or awk to extract data from Xml file

Hi, I want to get data from Xml file by using sed or awk command. I want to get the following result : mon titre 1;Createur1;Dossier1 mon titre 1;Createur1;Dossier1 and save it in cvs file (fichier.cvs). FROM this Xml file (test.xml): <playlist version="1"> <trackList> <track>... (1 Reply)
Discussion started by: yeclota
1 Replies
Login or Register to Ask a Question