0
4

3 に答える 3

1

cat -vet を使用して unix の制御文字を確認し、sed を使用してそれらの文字を置き換えることができます。以下の例では、cat -vet は (') を (M-^R) として表示しますが、これは sed を使用して簡単に置き換えることができます。

元のファイル:

My file contains an apostrophe (’). I am able to see this character if the file opens in Windows but not able to see it if the file opens in Unix. But I need to use that file once after removing that character.
I can't use windows to remove the character manually. My servers are Unix so I need to remove the character at that point. I have tried the following but it didn't work.

Unix の cat -vet で表示される制御文字:

/home/temp_files > cat -vet SO.txt
My file contains an apostrophe (M-^R). I am able to see this character if the file opens in Windows but not able to see it if the file opens in Unix. But I need to use that file once after removing that character.$
I can't use windows to remove the character manually. My servers are Unix so I need to remove the character at that point. I have tried the following but it didn't work.$

sed に置き換えます。

/home/temp_files > cat -vet SO.txt  | sed 's/M-^R//g'
My file contains an apostrophe (). I am able to see this character if the file opens in Windows but not able to see it if the file opens in Unix. But I need to use that file once after removing that character.$
I can't use windows to remove the character manually. My servers are Unix so I need to remove the character at that point. I have tried the following but it didn't work.$
于 2013-06-12T14:23:25.053 に答える
1
于 2013-06-12T12:58:14.983 に答える