中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-03 16:24
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Urgent] How to remove a fixed character from a text file with a single command
Printable Version  1,173 / 4
Floor1 liuchongs Posted 2006-05-09 16:43
新手上路 Posts 1 Credits 6
There is a file, for example 1.txt. I want to remove all the "\" characters in it.
What command should I use?
Floor2 xjmxjm1234 Posted 2006-05-09 18:21
中级用户 Posts 166 Credits 361
Use the text editing command edit, use Find and Replace, and replace all "/" with "" (empty).
Floor3 tigerpower Posted 2006-05-09 21:29
中级用户 Posts 99 Credits 377
Or use tr
tr -d \\ <1.txt>1_.txt

Attachments
tr.zip (12.57 KiB)
Floor4 namejm Posted 2006-08-26 22:57
荣誉版主 Posts 1,737 Credits 5,226 From 成都
  If there are no sensitive characters in the 1.txt file, then you can use the following code to remove "\" from the file
Floor5 g4rr Posted 2007-03-08 10:50
初级用户 Posts 32 Credits 68 From 广东潮州
This should work too, right? Hehe
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (1.txt) do (
set var=%%i
echo !var:\=!>>2.TXT
)
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023