|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
How to skip one item in a sh shell script? for x in 1 2 3; do if [ $x = "2" ]; then #??? how to skip 2 and proceed to 3? next ???? fi done Thanks ~Andrew Chen |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 2007-07-30, Andrew Chen wrote:
> Hi, > How to skip one item in a sh shell script? > > for x in 1 2 3; do > if [ $x = "2" ]; then > #??? how to skip 2 and proceed to 3? > next ???? > fi > done for x in 1 2 3; do if [ "$x" = 2 ]; then continue fi done -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Mon, 30 Jul 2007 19:38:32 -0000, Andrew Chen <hangfei@gmail.com>
wrote: >Hi, >How to skip one item in a sh shell script? > >for x in 1 2 3; do > if [ $x = "2" ]; then > #??? how to skip 2 and proceed to 3? > next ???? > fi >done > > >Thanks >~Andrew Chen You could use negative logic: for x in 1 2 3 do [ $x != 2 ] && { Do Whatever With X } done |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
hi
>Andrew Chen wrote: > Hi, > How to skip one item in a sh shell script? > > for x in 1 2 3; do > if [ $x = "2" ]; then > #??? how to skip 2 and proceed to 3? > next ???? > fi > done > for x in 1 3; do <whatever>; done -- good luck peter |
|
![]() |
| Outils de la discussion | |
|
|