Redirecting a List of Qshell Commands
September 20, 2006 Hey, Ted
I need a little help with a Qshell script. I retrieve a list of IFS files that have a certain extension (a suffix precede by a period) and pipe the list into another process. Now I have to also include other files that have a completely different extension. I do not want to run the command twice, processing each type of file in turn. How do I redirect the output of more than one command into one output stream? –Brad OK, let’s set up the problem for the benefit of the readers. Suppose Brad’s script currently processes files with the extension .TXT. Case of the extension is immaterial. ls *.[Tt][Xx][Tt] | sort -f > somefile Now he has to include .CSV files as well. The solution is to replace the single ls command with a list of commands. Just follow these easy steps.
Brad’s new command is the following: { ls *.[Tt][Xx][Tt]; ls *.[Cc][Ss][Vv]; } | sort -f > somefile All of the TXT and CSV files will be directed to the sort routine as one input stream. The braces force Qshell to process the commands concurrently. I have used the ls command in this illustration, but you may use any command that writes to standard output. –Ted |