shell脚本读取文件无法读入tab的解决方案。主要表现是读取到的行,没有了tab。
即使用 read line无法读入tab。
解决方法:
#!/bin/bash
# A shell script to read file line by line
filename="/var/log/xyz.log"
while IFS= read -r line
do
# $line variable contains current line read from the file
# display $line text on the screen or do something with it.
echo "$line"
done < $filename
方法2:
#!/bin/bash
IFS=$'\n'
for line in $(cat ./Survey.txt)
do
echo $line
done
Tags:
shell tab
shell tab