Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的文件:
1 2 3 <CR><LF> 1 2 3 <CR><LF> 1 2 3 <CR><LF>
每次我从中读取一行时,我应该怎么做才能得到“1 2 3”?
你可以这样做:
cat file | tr -d "\r" | while read line ; do echo $line ; done
经测试
printf "1 2 3\r\n4 5 6\r\n" | tr -d "\r" | while read line ; do echo $line ; done