How to remove carriage return and newline from a variable in shell script

前端 未结 6 1791
挽巷
挽巷 2020-12-01 05:57

I am new to shell script. I am sourcing a file, which is created in Windows and has carriage returns, using the source command. After I source when I append som

6条回答
  •  眼角桃花
    2020-12-01 07:02

    yet another solution uses tr:

    echo $testVar | tr -d '\r'
    cat myscript | tr -d '\r'
    

    the option -d stands for delete.

提交回复
热议问题