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 and shell scripting languages 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 08:40 AM
Help with find command and list in a long format each found file alexcol Shell Programming and Scripting 5 12-10-2007 08:59 AM
ksh: /usr/bin/ls: arg list too long jitindrabappa UNIX for Dummies Questions & Answers 2 10-12-2006 04:08 AM
Argument list too long - Shell error dad5119 Shell Programming and Scripting 8 03-03-2006 03:57 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2009
techmoris techmoris is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 27
ls command - strange error - arg list too long

I am running a shell script which has the following command

ls *.pdf | wc -l

error: arg list too long

Please post your thoughts on this..
  #2 (permalink)  
Old 08-21-2009
peterro peterro is offline
Registered User
  
 

Join Date: Jul 2009
Location: Gresham, OR
Posts: 154
Probably too many files in the directory for ls to handle. Try:


Code:
echo *.pdf | wc -w

  #3 (permalink)  
Old 08-21-2009
techmoris techmoris is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 27
great.....

This worked...

---------- Post updated at 02:08 PM ---------- Previous update was at 02:03 PM ----------

ls *.pdf > pdflist.txt

1.pdf
2.pdf
3.pdf
--
--

I have hundreds of pdf's in a directory and I want them in a pdflist.txt having one pdf in one line..can you guide me on this/..
  #4 (permalink)  
Old 08-21-2009
Leo Gutierrez Leo Gutierrez is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 13

Code:
find -maxdepth 1 -name "*.pdf" -print


Code:
find -maxdepth 1 -name "*.pdf" -print | wc -l


Last edited by Leo Gutierrez; 08-21-2009 at 03:46 PM..
  #5 (permalink)  
Old 08-21-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by techmoris View Post
I am running a shell script which has the following command

ls *.pdf | wc -l

error: arg list too long

Please post your thoughts on this..

There's no need for ls, and because it's an external command, its line length is limited to the system's maximum; printf is (usually) a shell builtin, and its line length is therefore limited only by memory.

Code:
printf *.pdf | wc -l

Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0