Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SED Command: How to append extracted data to the target file

Status
Not open for further replies.

alibaba786

Programmer
Feb 27, 2009
4
DE
I am trying to extract information by date from three different files and want to write in the result.txt file
Code:
File1.txt
----------
2009-02-24 12:13:29> [INFO] System version 6.2.0.26
2009-02-24 12:13:30> [INFO] HW version 2.4
2009-02-24 12:13:31> [INFO] Ocean version 5.6.5
2009-02-24 12:13:32> [INFO] Timezone 

File2.txt
2009-02-24 12:13:29> [INFO] numCANChannels = 2
2009-02-24 12:13:29> [INFO] numFlexRayChannels = 0
2009-02-24 12:13:29> [INFO] numLinChannels = 0
2009-02-24 12:13:29> [INFO] numMOST150Channels = 0

File3.txt
---------
2009-02-24 12:13:29> [INFO] ST10-MB bitrate = 4000000
2009-02-24 12:13:29> [INFO] getBitrateProc: /proc/driver
2009-02-24 12:13:29> [INFO] DSP-MB bitrate = 6000000

Trying to write extracted info to the result.txt file

Code:
sed -n -f '/^2009-02-24 12:13:29/,/^2009-02-24 12:13:33/p' File1.txt > result.txt 
sed -n -f '/^2009-02-24 12:13:29/,/^2009-02-24 12:13:33/p'
File2.txt > result.txt 
sed -n -f '/^2009-02-24 12:13:29/,/^2009-02-24 12:13:33/p'
File3.txt > result.txt

By this way , sed command overwrites the result.txt file , and show the result of the last command.
How can i append the data to the previously extracted data in the result.txt file

 
Use >>
Or use a single line command:
Code:
sed -n -e '/^2009-02-24 12:13:29/,/^2009-02-24 12:13:33/p' File[123].txt > result.txt

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top