Filter out output and then write to a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filter out output and then write to a file
# 1  
Old 11-09-2011
Filter out output and then write to a file

I have a process which writes lots of output to the screen and am capturing it to a file.

But the issue is that there are few lines which repeat every second which is causing the file size to be enormous. I am trying to filter out and then run the command but its not working.

Can you confirm if the below command is correct?

Code:
<process> | grep -v "java vm started" | tee 2>$1 ~/abc.log

# 2  
Old 11-09-2011
Code:

<process> | grep -v "java vm started" | tee 2>&1 ~/abc.log

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 11-09-2011
Sorry about the typo.

Yes, I used the above command but it did not work. As a matter of fact, the "process" runs all the time and writes output every second and the log file increases every second consequently.
Since, its not working wanted other option?
# 4  
Old 11-09-2011
are you sure you are searching for the correct string?...
can you paste the sample output of the process?...

--ahamed
# 5  
Old 11-09-2011
Ok, below are few lines which repeat:

Code:
Calling java class for read.
Java read returned no data currently available.
Calling java class for read.
Java read returned no data currently available.
Calling java class for read.
Java read returned no data currently available.

# 6  
Old 11-09-2011
But the search string is different... it is not matching right?
Code:
<process> | egrep -v "(Java read|java class)" | tee 2>&1 ~/abc.log

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 7  
Old 11-09-2011
Yes, the search string was different.

There were like 3 or 4 lines which repeat and I did not want to paste all the four search strings as it is similar to one of them.

Now then, I am using the same piece of code you mentioned and even then its not working. It is creating the file but is a zero byte file. Something else needs to be written to the log but command just not doing anything.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two and write updated output in third file

Hi Linux Experts. I have a requirement where i need to update the thousands of table definitions to extend the column length and character set therefore i am looking for some sort of linux script which i can use to update the length and chacterset. I have two files In first file i have 7... (1 Reply)
Discussion started by: Black-Linux
1 Replies

2. Shell Programming and Scripting

awk - read from a file and write conditional output

I have a file, which has '|' as separator; I need to read each line from that file and produce output to another file. While reading, I have certain condition on few specific columns (like column3 ='good'); only those lines will be processed. (3 Replies)
Discussion started by: mady135
3 Replies

3. Shell Programming and Scripting

Regex to split a string and write the output in another file.

hi, i am trying to write a script to generate ouput in the following format: ##### buildappi abcd_sh nodebug.##### ##### buildappi ijk_sh nodebug.##### The given string is as follows: xtopSharedDLLs = "abcd_sh def_sh ijk_sh " \ + "jkl_sh any_sh... (15 Replies)
Discussion started by: Rashid Khan
15 Replies

4. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

5. Shell Programming and Scripting

Write result to output file

Good morning everybody, Beeing an absolute newbie in shell scripting I would like to look for some help here. I would like to read an external text file and format the data and write it to an output file. What I was trying to do was to display the result (this worked). But now I... (1 Reply)
Discussion started by: bluejean1976
1 Replies

6. Red Hat

write execl output to file

hi, how to write the resullt of execl() into another file. i used write(fd,execl()); (1 Reply)
Discussion started by: Mahendravarma
1 Replies

7. Shell Programming and Scripting

Cut 2 fields and write to a output file

Hi, I am writing a code where the file is a pipe delimited and I would need to extract the 2nd part of field2 if it is "ATTN", "C/O" or "%" and check to see if field9 is populated or not. If field9 is already populated then leave it as is but if field9 is not populated then take the 2nd part of... (3 Replies)
Discussion started by: msalam65
3 Replies

8. Shell Programming and Scripting

output to write in a file

hi all, when i try to start an applicationserver for an example: ./kStart.sh > out.txt so kStart.sh script will start the application server and write the details to out.txt but in mycase... it is writing to out.txt and as well it is showing in the prompt also... I want only the... (2 Replies)
Discussion started by: raghur77
2 Replies

9. Shell Programming and Scripting

Write process output to a file

When I run <ls -l> to get a list of all the files, I want the displayed result to be written to a text file. Is there a way to do that? (1 Reply)
Discussion started by: kn.naresh
1 Replies

10. UNIX for Dummies Questions & Answers

Read from a file then filter the output

Hi i need a script which reads a certain file and then display it on the screen. The thing is i need to filter the display output. this is an example of the file which is to be loaded in the script. asdfg1.1.1|98 hjkldfe4.0.3|123 asdzxzvdweradfsdafascv10.0.10|123456789... (1 Reply)
Discussion started by: khestoi
1 Replies
Login or Register to Ask a Question