Re: Iterating over multiple arguments

From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 01/16/04


Date: 15 Jan 2004 23:51:49 GMT

On Thu, 15 Jan 2004 at 23:15 GMT, Dances With Crows wrote:
> This also works:
>
> samantha:~$ for ARG in one two three ; do
>> echo $ARG
>> done
>
> (If you enter "for ARG in one two three<ENTER>" you'll get a syntax
> error.

    Since when?

    I use that frequently, in shells from Bourne shell to bash and
    ksh; haven't had a syntax error yet.

> Terminate the list with ; , then add the do, and things will
> work as expected.)
>
>> I have tried the syntax you showed me on the bash shell, but it won't
>> work.
>
> The commands you use in bash are both scriptable and enterable one at a
> time from an interactive shell. Something that trips people up in some
> cases is the need to insert ; after every "line" when you're entering a
> command like the first one I wrote where it's all on one line. This is
> just the way bash is; there are other shells and scripting languages,
> and you may find another one more suited to the way you like to do
> things. (I like Perl for doing more complex things, but YMMV.) HTH,
>

-- 
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: PYTHONPATH
    ... The error indicates the shell tried to execute a program named '1' and couldn't find one. ... Arthimetic expressions generally have to be wrapped in ) in bash: ... non-interactive shell with the --login option, it first reads and executes ... commands from the file /etc/profile, ...
    (comp.lang.python)
  • Re: Command Line Interface
    ... > commands only for an administrator. ... Also how should I supress the bash shell and ... I would seriously consider a restricted shell ...
    (comp.os.linux.misc)
  • Re: Who makes training wheels for a 12" bike?
    ... Fire up Terminal.app and you are in bash with all rights and privileges. ... Bash is an sh-compatible command language interpreter that executes commands read ... Bash is intended to be a conformant implementation of the Shell and Utilities por- ... -c string If the -c option is present, then commands are read from string. ...
    (rec.bicycles.tech)
  • Re: Passing password in ssh
    ... I can picture a cron job that does a backup to a remote machine, or a backup client that uses an ssh link to communicate to a backup server on a remote machine using "unlocked" keys. ... You may want to look into the -r option of bash, ... You can also look into sudo to give limited access to commands that need to be run as root, if what you are doing is going to require it. ... It is designed to be used as the users shell on the remote machine when you want to limit what they can do over a ssh connection. ...
    (Fedora)
  • Re: New to Debian Linux - I have NASM experience under DOS 6.22
    ... > Maybe nasm is in the path, ... access to all the commands and NASM and so forth...hence, really, use ... up one big "man" page about _all_ the built-in commands the BASH shell ...
    (alt.lang.asm)

Loading