shell脚本读取文件无法读入tab的解决方案

Author: Bruce Liu Posted on: 2021-03-21 15:22:58 Visited: 289

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

相关主题:

留言信息:

......期待您的留言!


增加留言、提问或者评论,不用注册,匿名提交,你提交的信息经过审核后才会显示:


© 2008-2022 CunYouLu存有录博客 村友录 存游录 鲁ICP备08005943号