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..
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..
Probably too many files in the directory for ls to handle. Try:
echo *.pdf | wc -w
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/..
find -maxdepth 1 -name "*.pdf" -print
find -maxdepth 1 -name "*.pdf" -print | wc -l
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.
printf *.pdf | wc -l