Use Bash to read line by line and keep space

后端 未结 6 881
感情败类
感情败类 2020-11-28 05:00

When I use \"cat test.file\", it will show

1
 2
  3
   4

When I use the Bash file,

cat test.file |
while read data
do
    e         


        
6条回答
  •  醉梦人生
    2020-11-28 05:26

    IFS=''
    cat test.file |
    while read data
    do
        echo "$data"
    done
    

    I realize you might have simplified the example from something that really needed a pipeline, but before someone else says it:

    IFS=''
    while read data; do
        echo "$data"
    done < test.file
    

提交回复
热议问题