Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cat command 1

Status
Not open for further replies.

3inen

Technical User
May 26, 2005
51
US
Hi!
I have 8700 html files in a folder totaling 8.7 Mb size. I tried using the shell command “cat” to merge them into one file such as combined.html, but I get the response

“-bash: /bin/cat: Argument list too long”

any perl way of doing this.

Thanks in advance
 
Oh yes.
Perl should cope easily with that:
Code:
#!/usr/bin/perl -w
use strict;

foreach my $file (glob "*.html") {
  open FH, $file or die "Failed to open [$file]";
  print while(<FH>);
  close FH;
}
And redirect the output to your new output file.





(very injured) Trojan.
 
thanks! Trojan
just what i wanted.

cheers
 
I know this is a Perl forum, but I'm wondering if limiting the number of arguments sent to /bin/cat using xargs would fix the problem. For example:

Code:
ls *.html | xargs -l56 cat

The above limits the number of arguments sent to cat at 56 which should prevent the overflow.


 
Yep, sounds good to me.
Just remember though that windoze users would struggle with that.




(very injured) Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top