Redirect the output of the file based on String


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirect the output of the file based on String
# 1  
Old 06-02-2014
Tools Redirect the output of the file based on String

Hi,

I need to redirect the output of the file until the first instance of a string is found.

So in the filename output.txt i was to redirect everything from the start to where i find this string "BEA-000377" is found to a new file called output_new.txt

Sample output.txt
Code:
the controller calls the session bean to calculate the end date
5:24 PM the problem is how do i call the session bean from controller<BEA-000377>to
 me: controller does not cal session bean

Desired output:
Code:
the controller calls the session bean to calculate the end date
5:24 PM the problem is how do i call the session bean from controller<

OS: SunOS mymac 5.10 Generic_150400-09 sun4v sparc SUNW,SPARC-Enterprise-T5220
# 2  
Old 06-02-2014
Try:
Code:
sed '/BEA-000377.*/{s///; q;}' output.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

2. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

3. UNIX for Dummies Questions & Answers

redirect to a file based on a value in a field

Hi all! Is it possible with awk to redirect all the records of a file that match a string in a field to a specific file. input.tab: aaaaa|bbbbbb|KKKKK cccccc|dddddd|SSSSS eeeeee|ffffffff|SSSSS ggggg|hhhhhh|KKKKK redirected to 2 separate files depending on the value in $3: ... (3 Replies)
Discussion started by: lucasvs
3 Replies

4. Shell Programming and Scripting

How to redirect output of ls to a file?

Hi All, I want to redirect only the file names to a new file from the ls -ltr directroy. how Can i do it. my ls -ltr output will be as below. -rwxr-xr-x 1 118 103 28295 Jul 26 2006 event.podl -rwxr-xr-x 1 118 103 28295 Jul 26 2006 xyz.podl I want my new file... (6 Replies)
Discussion started by: girish.raos
6 Replies

5. Shell Programming and Scripting

redirect an awk string output to a script input with pipes

Hi, I have a function in a bash script that returns a string after some operations using awk. The following code returns 555 $VARIABLE="EXAMPLE" get_number $VARIABLE this value I'd like to pass it as a second argument of another script with the following usage myscript.sh <param1>... (7 Replies)
Discussion started by: rid
7 Replies

6. Shell Programming and Scripting

to search a string and redirect according to output

i have a file (kk.log) in which following contents are there: ===================================== Enter:YOU HAVE ENTERED : a TestCase: TC1226677371 IS PASSED 2009-02-25 13:57:33.444 INFO com.t.t.exporterporter - Initialising Xml Exporter.... 2009-02-25 13:57:33.445 INFO ... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

7. UNIX for Dummies Questions & Answers

redirect output to a file name

Hi all!! is possible to assign the output of some command to filename, i.e. grep_output.txt Otherwise, I want to open a new file which name is inside another, how can I do it? Thanks a lot! (7 Replies)
Discussion started by: csecnarf
7 Replies

8. Shell Programming and Scripting

Redirect grep output into file !!!!!

Hi, I am writing the following code in command prompt it is working fine. grep ',222,' SAPPCO_20080306.CSV_old > SAPPCO_20080306.CSV_new But the command is not working in the Shell Script... ########################################## #!/bin/sh #... (2 Replies)
Discussion started by: hanu_oracle
2 Replies

9. UNIX for Dummies Questions & Answers

Redirect output to a file

Ahhhrrrggg I'm having a brain fart... I want to take the output of a command and redirect it to a file... This works.... $ man cp | cat >> copy_help but this doesn't keytool -help |cat >> keytool_help It just produces... these lines... more keytool_help ] ... ... (11 Replies)
Discussion started by: jimmyc
11 Replies

10. Shell Programming and Scripting

redirect output to file?

Hi: I am currently working on a program which requires direct its ouput to a file here is an example ./proram arg_1 arg_2 when program ends all output will be arg_2 file Is that possible I am not a bad programmer, However I am stuck there. Can anyone give a hint? Thanks SW (1 Reply)
Discussion started by: slackware
1 Replies
Login or Register to Ask a Question