用文件中的Shell脚本替换字符

时间:2018-11-06 13:53:45

标签: shell unix replace

我在Unix中有一个txt文件,其中有一个特殊字符。 我需要替换所有特殊字符实例 我该如何在Shell脚本中进行操作?

这是我的代码。我需要在sftp之前替换所有特殊字符

turbolinks:before-visit

1 个答案:

答案 0 :(得分:0)

假设您有一个.txt文件,该文件在多个位置包含特殊字符(ý):

mayankp@mayank:~/$ cat test.txt 
"123","qweeerr","qqqqqq ý
rrrrr
hhhhhh",ý "sdfsfs" 

您可以从以下文件中替换ý

mayankp@mayank:~/$ sed -i 's/ý//g' test.txt 
mayankp@mayank:~/$ cat test.txt 
"123","qweeerr","qqqqqq 
rrrrr
hhhhhh", "sdfsfs"

您只需要在sed -i 's/ý//g' test.txt命令之前在脚本中添加行sftp

让我知道它是否有效。

相关问题