LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Shell Script to read 500files from the command line (http://www.linuxquestions.org/questions/programming-9/shell-script-to-read-500files-from-the-command-line-233693/)

saravanan1979 09-22-2004 02:07 AM

Shell Script to read 500files from the command line
 
Hi,
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
------------------

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

jim mcnamara 09-22-2004 09:44 AM

try:
Code:

for file in `echo $*`
do
  zcat $file
done
exit

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 02:53 AM.