China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 15:27
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Urgent] How to remove a fixed character from a text file with a single command View 1,172 Replies 4
Original Poster Posted 2006-05-09 16:43 ·  中国 河南 郑州 联通
新手上路
Credits 6
Posts 1
Joined 2006-05-09 16:40
20-year member
UID 55214
Status Offline
There is a file, for example 1.txt. I want to remove all the "\" characters in it.
What command should I use?
Floor 2 Posted 2006-05-09 18:21 ·  中国 上海 浦东新区 电信
中级用户
★★
论坛第一菜鸟
Credits 361
Posts 166
Joined 2006-04-15 13:23
20-year member
UID 53870
Status Offline
Use the text editing command edit, use Find and Replace, and replace all "/" with "" (empty).
Diskette Operating System
Floor 3 Posted 2006-05-09 21:29 ·  中国 上海 长宁区 电信
中级用户
★★
大师兄
Credits 377
Posts 99
Joined 2005-08-26 07:37
20-year member
UID 41945
Status Offline
Or use tr
tr -d \\ <1.txt>1_.txt
Attachments
tr.zip (12.57 KiB, Credits to download 1 pts, Downloads: 20)
Floor 4 Posted 2006-08-26 22:57 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  If there are no sensitive characters in the 1.txt file, then you can use the following code to remove "\" from the file

@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (1.txt) do (
set var=%%i
set "var=!var:\=!"
echo !var!>>2.txt
)
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2007-03-08 10:50 ·  中国 广东 广州 黄埔区 电信
初级用户
Credits 68
Posts 32
Joined 2007-01-24 04:00
19-year member
UID 77490
Gender Male
From 广东潮州
Status Offline
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
)
Forum Jump: