Sponsored Content
Full Discussion: Looping through input/output
Top Forums UNIX for Beginners Questions & Answers Looping through input/output Post 302979883 by Don Cragun on Saturday 20th of August 2016 09:46:46 PM
Old 08-20-2016
I apologize for guessing wrong at what combining.executable does. I made the unwarranted assumption that a file named infile1 would be your 1st input file and that a file named infile2 would be your second input file instead of infile1 being the name of your 2nd input file and infile2 being the name of your 1st input file.

With that list of files and no indication of what produced it, I'll make another wild assumption that the list is the first couple of lines of output from the command:
Code:
ls *header

and that the intent is that your input files are to be processed in increasing alphanumeric sorted order. Assuming that is correct (which based on the failure of my earlier assumptions is certainly not guaranteed), the following will combine your input files and produce an output file named outfile. It uses temporary files named 0 and 1 and renames the last used temporary file to be outfile and removes the other temporary file before it exits:
Code:
#!/bin/ksh
i=0
last=0
for file in *header
do	case "$i" in
	(0)	f1=$file
		i=1
		;;
	(1)	combining.executable "$file" "$f1" > $((out = last))
		i=2
		;;
	(2)	out=$((1 - last))
		combining.executable "$file" $last > $out
		last=$out
		;;
	esac
done
mv $out "outfile"
rm -f $((1 - out))

Although written and tested using a Korn shell, this will work with any shell that uses basic Bourne shell syntax and supports POSIX arithmetic substitutions (such as ash, bash, dash, and ksh; but not csh and its derivatives, and not a traditional Bourne shell).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Output from one command as input to another

This site has been very helpful thus far.. I thank you all in advance for sharing the knowledge. Let me get to it. I am trying to write a very small script to take away from the boredom of doing the same thing over and over. Everynow and again I have to get the hex value of a file using a... (2 Replies)
Discussion started by: BkontheShell718
2 Replies

2. UNIX for Advanced & Expert Users

input/Output settings

How can we view all the input/output settings of unix environment for a session (6 Replies)
Discussion started by: paritoshc
6 Replies

3. Shell Programming and Scripting

input -output file

Hi, I am having an Input file .which is having a list of names. comapring with our database , needs to write the out put in file called output.txt , format should be name--> country--->phone number could you please help me.. thanks in advance (7 Replies)
Discussion started by: hegdeshashi
7 Replies

4. Shell Programming and Scripting

perl: looping through the output of a 'system' command

Hi there could anybody point me in the right direction when it comes to looping through the output of a system command in perl (i.e. df -k) doing a test against each line to see if it matches? for example if i have a df -k output like this and I wanted to grab the lines that matched "sda" or... (3 Replies)
Discussion started by: rethink
3 Replies

5. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

6. Solaris

SVM Solaris 8 Problem. Metastat output looping

Hi friends, I'm newbie to SVM. Just wanna try installed it on one of our server (to do mirroring for disk0 and disk1) but i think im lost until now. :( the steps i've taken is as below:- 1.prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2 2.metadb -a -c 3 -f c1t0d0s7... (3 Replies)
Discussion started by: kronenose
3 Replies

7. Shell Programming and Scripting

Looping through for user input

Legends, I want to remain in the script until user passes the correct name. I had tried the below code; but it didn't work out. Please help echo "\nPlease enter the source system: \c" while read SYSTEM_NAME do if ]; then echo "\nMaking $SYSTEM_NAME as source system for particular... (5 Replies)
Discussion started by: sdosanjh
5 Replies

8. Shell Programming and Scripting

looping and saving output of each line separately

I have been trying this program for a long time. I am trying to read a file named "odon" line by line; read the first line, send it to do a command saved in a file "perm", once the first line has finished going through the content of the file perm, the result is saved with the number of the line.... (17 Replies)
Discussion started by: iconig
17 Replies

9. UNIX for Dummies Questions & Answers

Looping through the contents of array for output name

Hi all, I am trying to loop through the string contents of an array, to add it during the saving of the output files. I am trying this code to print each column and save it to unique file name, but it doesn't work. Thanks for any help. fnam=(japan usa uk) alldata.dat contained sample data... (1 Reply)
Discussion started by: ida1215
1 Replies

10. Shell Programming and Scripting

Looping over output of 'ls'

Hi, I have some output from 'ls' command and I want to loop over the output in a bash script. What would be a good way to go about it? For example, if the output of the ls command gives me 'prefix1 prefix2 prefix3', how can I set a loop that will iterate over these? many thanks! (5 Replies)
Discussion started by: pc2001
5 Replies
ESFILTER:(1)							   User Commands						      ESFILTER:(1)

NAME
esfilter - Output a filtered or truncated version of a ES SYNOPSIS
esfilter [actions/switches] <infile> <outfile> DESCRIPTION
TS tools version 1.11, esfilter built Nov 11 2008 17:15:39 Output a filtered or truncated version of an elementary stream. The input is either H.264 (MPEG-4/AVC) or H.262 (MPEG-2). The out- put is either an elementary stream, or an H.222 transport stream If output is to an H.222 Transport Stream, then fixed values for the PMT PID (0x66) and video PID (0x68) are used. Files: <infile> is the input elementary stream (but see -stdin below). <outfile> is the output stream, either an equivalent elementary stream, or an H.222 Transport Stream (but see -stdout and -host below). Actions: -copy Copy the input data to the output file (mostly useful as a way of truncating data with -max) -filter Filter data from input to output, aiming to keep every <n>th frame (where <n> is specified by -freq). -strip For H.264, output just the IDR and I pictures, for H.262, output just the I pictures, but see -allref below. Switches: -verbose, -v Output extra (debugging) messages -quiet, -q Only output error messages -stdin Take input from <stdin>, instead of a named file -stdout Write output to <stdout>, instead of a named file Forces -quiet. -host <host>, -host <host>:<port> Writes output (over TCP/IP) to the named <host>, instead of to a named file. If <port> is not specified, it defaults to 88. Implies -tsout. -max <n>, -m <n> Maximum number of frames to read (for -filter and -strip), or ES units/NAL units (for -copy). -freq <n> Specify the frequency of frames to try to keep with -filter. Defaults to 8. -allref With -strip, keep all reference pictures (H.264) or all I and P pictures (H.262) -tsout Output data as Transport Stream PES packets (the default is as Elementary Stream) -pes, -ts The input file is TS or PS, to be read via the PES->ES reading mechanisms. Not allowed with -stdin. Stream type: If input is from a file, then the program will look at the start of the file to determine if the stream is H.264 or H.262 data. This process may occasionally come to the wrong conclusion, in which case the user can override the choice using the following switches. If input is from standard input (via -stdin), then it is not possible for the program to make its own decision on the input stream type. Instead, it defaults to H.262, and relies on the user indicating if this is wrong. -h264, -avc Force the program to treat the input as MPEG-4/AVC. -h262 Force the program to treat the input as MPEG-2. TS tools version 1.11, esfilter built Nov 11 2008 17:15:39 Output a filtered or truncated version of an elementary stream. The input is either H.264 (MPEG-4/AVC) or H.262 (MPEG-2). The out- put is either an elementary stream, or an H.222 transport stream If output is to an H.222 Transport Stream, then fixed values for the PMT PID (0x66) and video PID (0x68) are used. Files: <infile> is the input elementary stream (but see -stdin below). <outfile> is the output stream, either an equivalent elementary stream, or an H.222 Transport Stream (but see -stdout and -host below). Actions: -copy Copy the input data to the output file (mostly useful as a way of truncating data with -max) -filter Filter data from input to output, aiming to keep every <n>th frame (where <n> is specified by -freq). -strip For H.264, output just the IDR and I pictures, for H.262, output just the I pictures, but see -allref below. Switches: -verbose, -v Output extra (debugging) messages -quiet, -q Only output error messages -stdin Take input from <stdin>, instead of a named file -stdout Write output to <stdout>, instead of a named file Forces -quiet. -host <host>, -host <host>:<port> Writes output (over TCP/IP) to the named <host>, instead of to a named file. If <port> is not specified, it defaults to 88. Implies -tsout. -max <n>, -m <n> Maximum number of frames to read (for -filter and -strip), or ES units/NAL units (for -copy). -freq <n> Specify the frequency of frames to try to keep with -filter. Defaults to 8. -allref With -strip, keep all reference pictures (H.264) or all I and P pictures (H.262) -tsout Output data as Transport Stream PES packets (the default is as Elementary Stream) -pes, -ts The input file is TS or PS, to be read via the PES->ES reading mechanisms. Not allowed with -stdin. Stream type: If input is from a file, then the program will look at the start of the file to determine if the stream is H.264 or H.262 data. This process may occasionally come to the wrong conclusion, in which case the user can override the choice using the following switches. If input is from standard input (via -stdin), then it is not possible for the program to make its own decision on the input stream type. Instead, it defaults to H.262, and relies on the user indicating if this is wrong. -h264, -avc Force the program to treat the input as MPEG-4/AVC. -h262 Force the program to treat the input as MPEG-2. SEE ALSO
The full documentation for esfilter is maintained as a Texinfo manual. Please check http://tstools.berlios.de for more information. esfilter 1.11 November 2008 ESFILTER:(1)
All times are GMT -4. The time now is 03:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy