-   Programming (
-   -   Shell Script to read 500files from the command line (

saravanan1979 09-22-2004 02:07 AM

Shell Script to read 500files from the command line
I use a shell script(see below) which takes 500 *.gz files(space separated) from the command line zcats them and passes the output to a second command via pipe pipe.(cmd a |cmd b|cmd c).But this method produces a data loss.Either all files are not read or the complete output is not escalated over the pipe.There is no error message returned.

Ps:The entire command(myzcat .sh @filelist|cmd b|cmd c ) is executed in Perl using IPC::Run module.The script has been thoroughly checked and defnitely 500 files are passsed as input to it.

Can anyone help me out in identifying the problem.

Shell Script used

echo "$filelist"|xargs zcat
if [ $? -eq 2 ]; then
exit 0

jim mcnamara 09-22-2004 09:44 AM


for file in `echo $*`
  zcat $file

It is possible to get odd behavior from either perl or shell by passing so many arguments. It's not the number of arguments but the total numbers of the characters.

I would make sure you don't pass more than 4096 characters at a time.

All times are GMT -5. The time now is 12:52 PM.