近期在windows上编辑一些shell脚本后上传到交换机框体上。
但这些shell脚本无法运行,每一行结尾都有'^M',同一时候框体上又没有dos2unix工具。
这么多脚本也不可能一行一行来改动。于是就自己写了一个脚本来把当前文件夹下全部文件里的'^M'去掉。

#!/bin/sh
filename='ls'

for f in ${filename};do
    if [ -f ${f} ]; then
        echo "delete '^M' and rename file to ${f}1"
        tr -d "\015" <${f}> ${f}1

        echo "Back to the original file name"
        mv ${f}1 ${f}
   fi
 done
 ll --color

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2021-09-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-07-05
  • 2022-12-23
相关资源
相似解决方案