2016-08-18 23 views
0

我有一個使用端到端的傳輸字符作爲IFS Bourne shell腳本:結束傳輸字符作爲IFS

ASCII_EOT=`echo -e '\004'` 
while IFS="$ASCII_EOT" read DEST PASSWORD; do 
    ... 
done 

怎樣的EOT表現爲一個IFS?或者read期望什麼樣的輸入?

+0

您確定它是Bourne shell腳本嗎? 'echo -e'意味着你使用'bash'或者外部的GNU'echo'二進制文件,在這種情況下,假設你可以使用'bash'來代替。 – chepner

回答

1

它是一個ASCII字符,就像,;它只是不可打印。

$ printf 'foo\004bar' > tmp.txt 
$ hexdump -C tmp.txt 
00000000 66 6f 6f 04 62 61 72 0a       |foo.bar.| 
00000008 
$ IFS=$(printf '\004') read f1 f2 < tmp.txt 
$ echo "$f1" 
foo 
$ echo "$f2" 
bar