The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Arg List too Long in SCP chris1234 UNIX for Dummies Questions & Answers 5 02-27-2008 05:40 AM
ls -t arg list too long CSU_Ram UNIX for Dummies Questions & Answers 4 05-05-2005 07:19 AM
arg list too long encrypted UNIX for Advanced & Expert Users 8 11-12-2004 03:38 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 03:38 PM
arg list too long vingupta UNIX for Dummies Questions & Answers 5 08-02-2001 08:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-02-2006
Registered User
 

Join Date: Mar 2006
Posts: 4
Question Argument list too long - Shell error

Trying to tar specific files from a directory causes problems when the number of files is too large.

ls ~/logs | wc -l
5928

In the logs directory - I have 5928 files

If I want to include all files with today's date - I run the following command

tar cf ~/archive/LoadLogs_20060302.tar ~/logs/LoadLog_20060302_*.log

However, I get the following error:

/usr/bin/tar: Argument list too long

Any suggestions on how to correct this would be appreciated.

Thanks,

Rick

Last edited by dad5119; 03-02-2006 at 01:31 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 03-02-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,608
Your tar command doesn't look right. You need something like:
tar cf ~/archive/LoadLogs_20060302.tar ~/logs/LoadLog_20060302_*.log
Reply With Quote
  #3  
Old 03-03-2006
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 130
You can specify an "include file" usually with a -I option. To use, create a directory listing into the include file:

ls -1 ~/logs/LoadLog_20060302_*.log > /tmp/tar.include

Then run the tar command

tar -cf ~/archive/LoadLogs_20060302.tar -I /tmp/tar.include
Reply With Quote
  #4  
Old 03-03-2006
Registered User
 

Join Date: Mar 2006
Posts: 4
Argument list too long for multiple commands

Thanks for the suggestions - however when I use an asterisk in my matching criteria (even for the "ls" command) - I get the same error.

I guess the default limit for an argument list is used for ALL commands.
Commands like "ls" "gzip" "tar" "cp" "mv" "cat" - all complain when I try to limit the argument list.

I was hoping there was some shell configuration setting that would increase the allowable size - but I'm beginning to think that it's the programs problem - not the shell environment.

Rick
Reply With Quote
  #5  
Old 03-03-2006
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 130
Quite right, I should have seen that coming. Use the find command to generate the include file:

find ~/logs/ -name "LoadLog_20060302_*.log" > /tmp/tar.include

This isn't AIX by chance is it?
Reply With Quote
  #6  
Old 03-03-2006
Registered User
 

Join Date: Feb 2006
Location: Southern England
Posts: 102
not c shell by any chance?
Reply With Quote
  #7  
Old 03-03-2006
Registered User
 

Join Date: Mar 2006
Posts: 4
Not C shell.
Running ksh on Unix and Linux - same results on both.

Thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0