108 ¹ø ±Û: [SHELL] ¶óÀδÜÀ§·Î Àоî¿À±â |
±Û¾´ÀÌ: »êÀÌ
[ȨÆäÀÌÁö]
|
±Û¾´³¯: 2005³â 01¿ù 02ÀÏ 05:57:22 ÀÏ(»õº®) |
Á¶È¸: 3461 |
-- example.sh -----------------------------
#!/bin/sh
OIFS=$IFS
TT="10
21 22 23 2444444444444444
30 31
50
61
70
"
echo '------------------------------------'
echo 'orignal string'
echo "$TT"
echo '------------------------------------'
echo '------------------------------------'
echo 'for() test with default IFS'
echo '------------------------------------'
for n in $TT ; do
echo "'$n'"
done
IFS='
'
echo '------------------------------------'
echo 'for() test with \r\n IFS'
echo '------------------------------------'
for n in $TT ; do
echo "'$n'"
done
IFS=$OIFS
echo '------------------------------------'
echo 'pipe and read test with default IFS'
echo '------------------------------------'
echo "$TT" | while read line etc ; do
echo "'$line' '$etc'"
done
IFS='
'
echo '------------------------------------'
echo 'pipe and read test with \r\n IFS'
echo '------------------------------------'
echo "$TT" | while read line etc ; do
echo "'$line' '$etc'"
done
IFS=$OIFS
echo '------------------------------------'
echo 'stdin read file with default IFS'
echo '------------------------------------'
while read line etc ; do
echo "'$line' '$etc'"
done < /tmp/foo.txt
IFS='
'
echo '------------------------------------'
echo 'stdin read file with \r\n IFS'
echo '------------------------------------'
while read line etc ; do
echo "'$line' '$etc'"
done < /tmp/foo.txt
IFS=$OIFS
echo '------------------------------------'
echo 'single line read with default IFS'
echo '------------------------------------'
echo "some foo bar comment" |
{
read first second others
echo "'${first}' '${second}' '${others}'"
}
IFS='
'
echo '------------------------------------'
echo 'single line read with default IFS'
echo '------------------------------------'
echo "some foo bar comment" |
{
read first second others
echo "'${first}' '${second}' '${others}'"
}
echo
echo "external variable test: '${first}'" ## is empty
exit 0
---------------------------------------------------
// result
------------------------------------
orignal string
------------------------------------
10
21 22 23 2444444444444444
30 31
50
61
70
------------------------------------
for() test with default IFS
------------------------------------
'10'
'21'
'22'
'23'
'2444444444444444'
'30'
'31'
'50'
'61'
'70'
------------------------------------
for() test with \r\n IFS
------------------------------------
'10'
' 21 22 23 2444444444444444'
'30 31'
'50'
' 61'
'70'
------------------------------------
pipe and read test with default IFS
------------------------------------
'10' ''
'21' '22 23 2444444444444444'
'30' '31'
'' ''
'50' ''
'' ''
'' ''
'61' ''
'70' ''
'' ''
------------------------------------
pipe and read test with \r\n IFS
------------------------------------
'10' ''
' 21 22 23 2444444444444444' ''
'30 31' ''
'' ''
'50' ''
'' ''
'' ''
' 61' ''
'70' ''
'' ''
------------------------------------
stdin read file with default IFS
------------------------------------
'111' '22222'
'file' ''
'foo' ''
------------------------------------
stdin read file with \r\n IFS
------------------------------------
'111 22222' ''
' file' ''
'foo' ''
------------------------------------
single line read with default IFS
------------------------------------
'some' 'foo' 'bar comment'
------------------------------------
single line read with default IFS
------------------------------------
'some foo bar comment' '' ''
external variable test: ''
|
ÀÌÀü±Û : [MySQL] mysql memory setting table
´ÙÀ½±Û : [PHP & SHELL] daemon mode -- background
|
from 61.254.75.78
JS(Redhands)Board 0.4 +@
|