Redirecting part of output to stdout | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Redirecting part of output to stdout

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-15-2008
Legend986 Legend986 is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 13 May 2010, 3:07 PM EDT
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Redirecting part of output to stdout

Hi,

I am trying to execute a command like this:


Code:
find ./ -name "*.gz" -exec sh -c 'zcat {} | awk -f parse.awk' \; >> output

If I want to print the filename, i generally use the -print argument to the find command but when I am redirecting the output to a file, how can I print just the filenames into stdout with the rest of the output into the file? Any help is much appreciated.

EDIT: Ah... Figured out... Sorry... Here's the solution:


Code:
find ./ -name "*.gz" -exec sh -c 'zcat {} | awk -f parse.awk >> output' \;

The solution was to put the redirection inside the exec itself...
Sponsored Links
    #2  
Old 10-17-2008
otheus's Avatar
otheus otheus is offline Forum Advisor  
Smartass
 
Join Date: Feb 2007
Last Activity: 3 December 2014, 3:10 AM EST
Location: Innsbruck, Austria
Posts: 2,153
Thanks: 12
Thanked 49 Times in 46 Posts
Well done!
Sponsored Links
    #3  
Old 10-17-2008
Legend986 Legend986 is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 13 May 2010, 3:07 PM EDT
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Thank You Just learning Unix so got curious in messing around with things...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Redirecting stdout on background task salukibob Shell Programming and Scripting 1 07-25-2011 11:51 AM
Redirecting stdout to variable while printing it ocirne94 Shell Programming and Scripting 2 03-18-2011 05:46 PM
Preserve output order when redirecting stdout and stderr Boemm Shell Programming and Scripting 8 12-29-2009 12:22 PM
Redirecting several outputs to /dev/stdout aplaydoc UNIX for Dummies Questions & Answers 1 03-06-2009 11:42 PM
redirecting STDOUT & STDERR jshinaman Shell Programming and Scripting 9 06-22-2007 01:04 AM



All times are GMT -4. The time now is 11:11 PM.