Linked Questions

7
votes
4answers
12k views

maximum number of files ls can list [duplicate]

Im using a script to delete old file in a directory, but the script kept showing /usr/bin : Argument list too long It turned out the number of files were 40000 and more, So I want to know what is ...
49
votes
3answers
39k views

What defines the maximum size for a command single argument?

I was under the impression that the maximum length of a single argument was not the problem here so much as the total size of the overall argument array plus the size of the environment, which is ...
13
votes
4answers
8k views

How to cause “Argument list too long” error? [duplicate]

Context for the question: According to POSIX specs, ARG_MAX is maximum length of command-line arguments to exec() family of functions. Which lead me to believe that's actual number of arguments, ...
12
votes
4answers
10k views

How do I get a single total of lines with `wc -l`?

I've added a git alias to give me the line counts of specific files in my history: [alias] lines = !lc() { git ls-files -z ${1} | xargs -0 wc -l; }; lc However, wc -l is reporting multiple totals, ...
11
votes
2answers
2k views

Is there a maximum to bash file name expansion (globbing) and if so, what is it?

Is there a maximum to bash file name expansion (globbing) and if so, what is it? See globbing on tldp.org. Let's say I want to run a command against a subset of files: grep -e bar foo* rm -f bar* ...
5
votes
3answers
2k views

Shell Script: Copy first file from multiple folders into one single folder

In a directory, I have hundreds of sub-directories. Each sub-directory has hundreds of jpg pictures. If the folder is called "ABC_DEF", the files inside the folder will be called "ABC_DEF-001.jpg", "...
1
vote
3answers
2k views

shell script for auto-touching files

I have written a shell script to touch all the files in the /tmp directory. However, there was an error message saying that /bin/touch: Argument list too long. What's the cause of the problem? #!/bin/...
3
votes
2answers
881 views

shopt -s extglob not working as expected

I am trying to recursively change file permissions in a wordpress installation affecting everything below the public_html document root folder, excluding certain folders. I have set extglob on with ...
5
votes
3answers
1k views

Why not use backticks with for loop

Some time ago, I posted answer to some question about scripting. Someone pointed out that I shouldn't use following command: for x in $(cat file); do something; done but instead of that: while ...
4
votes
1answer
1k views

Is the Linux implementation of the system configuration “variable” ARG_MAX different from other system variables and is it POSIX compliant?

In the shell, as explained in this this Q&A in the context of expansion, depending on the system, the maximum length of a command's argument is initially constrained by the kernel setup. The ...
0
votes
1answer
1k views

what is the maximum character range of grep in bash?

What is the maximum character range of grep in bash? How long can a string be as input to search using the grep command?