LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-18-2007, 02:43 PM   #1
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
Cannot redirect files from egrep...


OK, so there's an easy workaround, but I'd like to understand what's going on:

I was wanting to try to diagnose a problem with kaffeine, so I attached an strace to its process, and redirected the output to a log file:

strace -p 19205 2>kaff.log

This worked fine, but produced an overwhelming amount of output, though, so I passed it through egrep to filter out the trivial (or continuous) output:

strace -p 19205 2>&1 | egrep -v '(^ioctl|^gettimeofday|^select|^read|^write|^poll)' > kaff.log

No output arrived in the file. However, if I remove the file redirection then I get the expected output whenever I click a button (or similar).

Thanks,
Rob
 
Old 08-18-2007, 02:48 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Works here ... which distro and what shell do you have that problem with?



Cheers,
Tink
 
Old 08-18-2007, 02:58 PM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
The order of redirection statements makes a difference. Your command firstly tells the shell to send stderr to the same place that stdout is currently pointing to (usually the current terminal window). Then you tell stdout to go to the file, but stderr will still go where you originally sent it and is not changed by changing stdout afterwards. All you should need to do is:
Code:
strace -p 19205 | egrep -v '(^ioctl|^gettimeofday|^select|^read|^write|^poll)' > kaff.log 2>&1
or
strace -p 19205 | egrep -v '(^ioctl|^gettimeofday|^select|^read|^write|^poll)' &>kaff.log
I've assumed you're using the bash shell. There's more info on this in man bash if you search for redirection.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect output object files using a linux kernel Makefile? archieval Linux - Newbie 0 06-28-2007 12:14 AM
how to redirect kernel messages to user files sharad durgawad Linux - Software 4 12-09-2005 07:33 PM
egrep multiple files smart_sagittari Linux - Newbie 2 06-27-2005 08:57 AM
Help with egrep smart_sagittari Linux - Newbie 2 05-02-2005 08:18 AM
Using egrep Barbarian Programming 5 10-20-2002 02:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration