l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2004 Apr 28 22:27

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Bash scripting newbie - need syntax help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Bash scripting newbie - need syntax help

On Tue, 27 Apr 2004, Larry Ozeran wrote:

> Hi all -
> [...]
> [root@localhost mailman]# rm -f error.*
> bash: /bin/rm: Argument list too long
> [...]
> The idea is that if it can't erase all files "error.1*" because there are too many, it calls itself again and tries "error.1.1*", and so forth.
> [...]
> I read through the bash man page 3 times, but couldn't get enough out of
> it to understand the error message: unexpected Do on line 4. The man
> page said the syntax of the for loop was "for ((exp; exp; exp)); do exp;
> done", which is what I thought I had.

Hi Larry,

Try using xargs like this:

find . -name "error*" | xargs rm

You can also try doing it through the find command like this:

find . -name "error*" -exec rm \{} \;

Finally, if you still want to get your for loop to work, you should write 
your for loop like this:

for (( i=1; i<5; i++ )); do
  echo $i  # sub your own command here

Notice there are no dollar signs in the assignment, the comparison, nor 
the increment.


vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.