有一个 test.txt 的文件中有一个符号 → 需要删除掉,谁来帮忙写一个?
1
adexbn 2016-07-14 10:36:00 +08:00
Alins-MBA:Downloads alin$ echo → >> test.txt
Alins-MBA:Downloads alin$ cat test.txt → → Alins-MBA:Downloads alin$ sed -i -e 's/\→//g' test.txt Alins-MBA:Downloads alin$ cat test.txt Alins-MBA:Downloads alin$ |
2
knightdf 2016-07-14 10:37:06 +08:00
sed -i 's/→/x/g' test.txt
|
4
adexbn 2016-07-14 10:38:09 +08:00
[root@cm-redirector ~]# rm -f test.txt
[root@cm-redirector ~]# clear [root@cm-redirector ~]# uname -a Linux cm-redirector 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [root@cm-redirector ~]# echo → >> test.txt [root@cm-redirector ~]# echo → >> test.txt [root@cm-redirector ~]# cat test.txt → → [root@cm-redirector ~]# sed -i 's/\→//g' test.txt [root@cm-redirector ~]# cat test.txt [root@cm-redirector ~]# |
6
awanabe 2016-07-14 10:48:36 +08:00
打开编辑器, 选择替换, 替换成'' 不就全部删掉了
|
7
lowzoom 2016-07-14 10:49:22 +08:00
@adexbn 难道不是 Windows 下的脚本才叫批处理?
https://en.wikipedia.org/wiki/Batch_file A batch file is a kind of script file in DOS, OS/2 and Windows. |
11
ETiV 2016-07-14 11:59:29 +08:00 via iPhone
我都忘了 Windows bat 文件中文名叫批处理……
|
13
adexbn 2016-07-14 13:34:14 +08:00
@c7898585
-----以下是代码 @echo off setlocal enabledelayedexpansion set INTEXTFILE=test.txt set OUTTEXTFILE=test_out.txt set SEARCHTEXT=→ set REPLACETEXT= set OUTPUTLINE= for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do ( SET string=%%A SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%! echo !modified! >> %OUTTEXTFILE% ) del %INTEXTFILE% rename %OUTTEXTFILE% %INTEXTFILE% |
14
c7898585 OP @adexbn
................ 这个命令把所有的内容头替换成了 string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= string:= |
15
kenshin912 2016-07-14 13:59:38 +08:00
https://sourceforge.net/projects/fart-it/
下载回来的是 fart.exe 批处理调用这个 fart.exe 即可. @echo off set text=→ set replace= %~dp0fart.exe test.txt %text% %replace% exit 完事 |
16
c7898585 OP @kenshin912 found one file
但是无法删除。。。 |
17
naomhan 2016-07-15 09:51:17 +08:00
我怎么感觉是 tab 缩进符号
|