11/21/2016
url: http://stackoverflow.com/questions/1445452/shell-script-for-loop-syntax
dlyelgg@lgpbd1070[(IPC2-Gold-EDGE) ~/srik]$ vi Forloop_example.sh
#Lists= $(ls *.sh)
for List in ${1...10}
do
echo "File name from the list: ${List}"
done
---------------------------
#!/bin/bash
#Lists= $(ls *.sh)
Lists= "red green yellow"
for List in $Lists
do
echo "File name from the list: $List"
done
O/P:
: command not found line 4: red green yellow
'orloop_example.sh: line 6: syntax error near unexpected token `do
'orloop_example.sh: line 6: `do
---------------------------
max=10
for (( i=2; i <= $max; ++i ))
do
echo "$i"
done
O/P:
syntax error near unexpected token `
'orloop_example.sh: line 6: `for (( i=2; i <= $max; ++i ))
-------------
for i in {2..10}
do
echo "output: $i"
done
for List in {1...10}
do
echo "File name from the list: $List"
done
o/p: syntax error near unexpected token `do
'orloop_example.sh: line 6: `do
-----------------------------------------
max=10
for i in `seq 2 $max`
do
echo "$i"
done
-----------
for i in {1..5}; do
echo $i
done
o/p:
syntax error near unexpected token `do
'orloop_example.sh: line 5: `for i in {1..5}; do
url: http://stackoverflow.com/questions/1445452/shell-script-for-loop-syntax
dlyelgg@lgpbd1070[(IPC2-Gold-EDGE) ~/srik]$ vi Forloop_example.sh
#Lists= $(ls *.sh)
for List in ${1...10}
do
echo "File name from the list: ${List}"
done
---------------------------
#!/bin/bash
#Lists= $(ls *.sh)
Lists= "red green yellow"
for List in $Lists
do
echo "File name from the list: $List"
done
O/P:
: command not found line 4: red green yellow
'orloop_example.sh: line 6: syntax error near unexpected token `do
'orloop_example.sh: line 6: `do
---------------------------
max=10
for (( i=2; i <= $max; ++i ))
do
echo "$i"
done
O/P:
syntax error near unexpected token `
'orloop_example.sh: line 6: `for (( i=2; i <= $max; ++i ))
-------------
for i in {2..10}
do
echo "output: $i"
done
for List in {1...10}
do
echo "File name from the list: $List"
done
o/p: syntax error near unexpected token `do
'orloop_example.sh: line 6: `do
-----------------------------------------
max=10
for i in `seq 2 $max`
do
echo "$i"
done
-----------
for i in {1..5}; do
echo $i
done
o/p:
syntax error near unexpected token `do
'orloop_example.sh: line 5: `for i in {1..5}; do
No comments:
Post a Comment