1

I am a beginner programming shell scripts, right now I am doing a shell script to create zip files according to last modification of directory inside a path. Where date is:

today=date +%Y-%m-%d

customers=find /DOMINOAPP/Delta_Transfer/*/* -type d -name "*" -newermt $today | cut -d "/" -f4

I got this error:

./zips.sh: line 8: /bin/find: Argument list too long

Please anyone could you help me to fix this issue?

1 Answer 1

1

Wildcards (outside of strings) are expanded by the shell, so here /DOMINOAPP/Delta_Transfer/*/* is first expanded by the shell, then passed to find. If it contains a lot of files the list will be super long and you’ll get that error.

find already goes into all subdirectories, so you can remove those wildcards:

find /DOMINOAPP/Delta_Transfer -type d -name "*" -newermt $today 

To better understand wildcard expansion by the shell, compare the following commands:

$ touch a1 a2 a3 $ echo a* # <-- expansion, = 'echo a1 a2 a3' a1 a2 a3 $ echo "a*" # <-- no expansion, = 'echo a*' a* 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.