[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] how to understand the xargs
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] how to understand the xargs |
Date: |
Tue, 27 Dec 2011 10:16:26 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Dec 27, 2011 at 11:12:31PM +0800, lina wrote:
> #!/bin/sh
>
> for i in {1..10} ; do
Brace expansion is a bash feature, not a /bin/sh feature. When you put
#!/bin/sh at the top of your script, you are telling the operating system
to use /bin/sh as the interpreter when you run the script. And /bin/sh
won't understand brace expansions.
If you wish to use bash features in your scripts, you must use
#!/bin/bash
or
#!/usr/bin/env bash
as your shebang. This will make the operating system run bash to interpret
your script.
> BTW, on script I used to use for i in $(seq 10)
> just recent trying to learn more, so do some practice.
seq(1) is Linux-only. Some other OSes have jot(1) instead, but both of
those are nonstandard (and they have incompatible syntax).
The correct way to count to 10 in /bin/sh is:
i=1
while [ $i -le 10 ]; do
...
i=$((i+1))
done
- [Help-bash] how to understand the xargs, lina, 2011/12/27
- Re: [Help-bash] how to understand the xargs, lina, 2011/12/27
- Re: [Help-bash] how to understand the xargs, Greg Wooledge, 2011/12/27
- Re: [Help-bash] how to understand the xargs, lina, 2011/12/27
- Re: [Help-bash] how to understand the xargs,
Greg Wooledge <=
- Re: [Help-bash] how to understand the xargs, lina, 2011/12/27
- Re: [Help-bash] how to understand the xargs, Greg Wooledge, 2011/12/27
- Re: [Help-bash] how to understand the xargs, lina, 2011/12/27
- Re: [Help-bash] how to understand the xargs, Greg Wooledge, 2011/12/27
- Re: [Help-bash] how to understand the xargs, lina, 2011/12/27
Re: [Help-bash] how to understand the xargs, Dan Douglas, 2011/12/28