Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Redirecting stdout inside a loop Post 302912676 by hmortens on Monday 11th of August 2014 10:52:08 AM
Old 08-11-2014
ok I spent ages on my reply and then lost it when trying to post, so here it is again. bah...
You had asked
Quote:
You have told us a lot about which lines were messing up, but what's less clear is what you'd want the program to be doing, if it were working.
Apologies for not being totally clear. I currently have a bash script that is run from a project directory location that contains many Sample directories. The script contains a for loop that is running three third party tools on files in each Sample Directory. I have added a loop within this loop (probably bad form!) to pull a file ('summary.txt') from one program output directory for each sample and print all summary.txt files to a single .txt. Lastly, I direct all stout from the script to a second .txt file.
I would like select specific lines from stout for each sample (or iteration of the loop), and print with each summary.txt, so that I get a report for all Samples for QA purposes. This would need to be in order of Sample processing through the loop to be readable, for Example: sample 1 stout lines, sample1 summary
sample 2 stout lines, sample2 summary.....

This output text file would look something like this (THIS IS OUTPUT FROM CODE, NOT CODE!):
Code:
Sample1
Processed reads: 4378294
Total reads:54783243
Summary Report Sample 1:XXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
SampleN
Processed reads: 213221213
Total reads:33213333
Summary Report Sample 1:XXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Now, I can put all summary files in a single .txt and pull the whole stout to a second .txt, but have not been able to select stout lines within the loop and iterate with printing the summary.
All suggestions welcome!
Moderator's Comments:
Mod Comment CODE tags should be used whenever you are displaying sample input, sample output, and code segments; not just code segments!

Last edited by Don Cragun; 08-11-2014 at 02:03 PM.. Reason: Put CODE tags back in!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirecting STDOUT & STDERR

In bash, I need to send the STDOUT and STDERR from a command to one file, and then just STDERR to another file. Doing one or the other using redirects is easy, but trying to do both at once is a bit tricky. Anyone have any ideas? (9 Replies)
Discussion started by: jshinaman
9 Replies

2. Shell Programming and Scripting

implicitly redirecting stdout to a file

Is there a way to redirect all stdout to a file implicitly - like defining stdout=/home/me/process.log - so that all "echo" commands in several scripts/subscripts are written to that file; instead of having to edit all scripts to redirect the "echo" (e.g. echo 'This is a test ' >>... (1 Reply)
Discussion started by: ALTRUNVRSOFLN
1 Replies

3. Shell Programming and Scripting

Redirecting part of output to stdout

Hi, I am trying to execute a command like this: 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... (2 Replies)
Discussion started by: Legend986
2 Replies

4. UNIX for Dummies Questions & Answers

Redirecting several outputs to /dev/stdout

I have an executable that, depending on its input, outputs to either one file or several. It usually prints nothing on screen. The usual way to call this program is to specify an input and output filenames, like this: ./executable.exe -i inputfile -o outputfileIt will then try to use the output... (1 Reply)
Discussion started by: aplaydoc
1 Replies

5. Shell Programming and Scripting

redirecting to stdout in betwen command

can anyone help me in making singleline command for Capital Letters are folders ,small letter are files X,Y,Z are subfolders of A as shown below A - X,Y,Z Folder X has three files a.txt,b.txt,c.txt similarly Y,Z. as shown below X- a.txt,b.txt,c.txt Y- a.txt,b.txt,c.txt Z-... (4 Replies)
Discussion started by: phoenix_nebula
4 Replies

6. Shell Programming and Scripting

Redirecting stdout to variable while printing it

Hi everybody, I am trying to do the thing you see in the title, and I can't simply do a=$(svn up) echo $a because the program (svn) gives output on lots of lines and in the variable the output is stored on only one line (resulting in a horribly formatted text). Any tips? Thanks,... (2 Replies)
Discussion started by: ocirne94
2 Replies

7. Shell Programming and Scripting

Redirecting stdout on background task

Hello, I have a script (videostream.sh) which invokes the GStreamer command-line tool gst-launch with all the correct command line parameters. When I invoke this program, I add the '&' character at the end to make it a background task, so that my script can complete and exit, i.e. gst-launch... (1 Reply)
Discussion started by: salukibob
1 Replies

8. Shell Programming and Scripting

Redirecting stdout problem

I have a simple bash script that prints sth every 5 seconds. What I do is the following. I redirect the output of the script to a file, tail the file and see that it works and then from another console I delete the file where the output is redirected to. Even though I have deleted the file, the... (2 Replies)
Discussion started by: igurov
2 Replies

9. Shell Programming and Scripting

Redirecting stdout continously to a file

I have a C program that continously outputs info to stdout. The problem is that I am redirecting the stdout and stderr to a file and stdout is written at the end of the problem rather than continously to the file. This could be a problem if for example the program is killed and the stdout output is... (3 Replies)
Discussion started by: igurov
3 Replies

10. Shell Programming and Scripting

Redirecting stdion, stdout within an AT command

Hello, I'm strugling with some redirecting and all help is apreciated. The following program is working as expected, but the result of the AT command doesn't go to any file. Thanks in advance for the help. #!/bin/bash modem=/dev/ttyUSB1 file=/root/imsi.txt # print error to stderr and exit... (4 Replies)
Discussion started by: cleitao
4 Replies
esdctl(1)							   User Commands							 esdctl(1)

NAME
esdctl - Enlightened Sound Daemon (esd) control program SYNOPSIS
esdctl [-h] [-s hostname:port] command DESCRIPTION
The esdctl utility is a command-line control program for the Enlightened Sound Daemon (esd). OPTIONS
The following options are supported: -s hostname:portContact the esd server on hostname at port. You can also specify this option as follows: --server=hostname:port -h Display help text, and exit. OPERANDS
The following operands are supported: command The following commands are supported: allinfo Get player and sample information from the server cache sample Cache a sample in the server free name Uncache a sample in the server getid name Retrieve a sample id, given the sample name lock Do not allow foreign clients to use the server loop name Make a cached sample loop off Suspend sound output so that other programs can use the audio device (this is the same as the standby option) on Resume sound output so that only esd can use the audio device (this is the same as the resume option) pansample id lefSetidefault panning for a sample, where id is the sample ID, and left and right are integers in the range 0 to 255 panstream id lefSetipanning for a stream, where id is the stream ID, and left and right are integers in the range 0 to 255 play name Play a cached sample once resume Resume sound output so that only esd can use the audio device (this is the same as the on option) serverinfo Get server information from the server standby Suspend sound output so that other programs can use the audio device (this is the same as the off option) standbymode Check whether the server is on standby stop name Stop the looping sample at the end unlock Allow foreign clients to use the server EXAMPLES
Example 1: Putting esd into Standby Mode example% esdctl standby Example 2: Ending Standby Mode example% esdctl resume Example 3: Loading a sample into the esd cache example% esdctl cache info.wav Sample <3> uploaded. Name = esdctl:info.wav This output indicates that the sample id is 3, and the sample name is esdctl:info.wav. Example 4: Getting a sample id from the esd cache example% esdctl getid esdctl:info.wav Example 5: Playing a sample from the esd cache example% esdctl play esdctl:info.wav Example 6: Playing and looping a sample example% esdctl loop esdctl:info.wav Example 7: Stopping a looped sample that is being played example% esdctl stop esdctl:info.wav Example 8: Removing a sample from the esd cache example% esdctl free esdctl:info.wav Example 9: Setting panning for a stream example% esdctl panstream 1 100 155 Example 10: Setting panning for a sample example% esdctl pansample 1 155 100 EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/esdctl Executable for Enlightened Sound Daemon control program ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-audio | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
esdcat(1), esdplay(1), esdrec(1), esdsample(1), esdmon(1), esd-config(1), libesd(3) NOTES
Written by Brian Cameron, Sun Microsystems Inc., 2003. SunOS 5.10 8 Jan 2003 esdctl(1)
All times are GMT -4. The time now is 11:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy