[英]Remove last instance of \ in a text file
I would like to strip, up to last instance of \
, in a text file.我想在文本文件中\
的最后一个实例。 The \
is in a floating position and different occurrences. \
在浮动 position 和不同的出现中。
I would like to implement this from a Unix command line and put it into a shell script.我想从 Unix 命令行实现这个并将其放入 shell 脚本中。 This is for windows 10 v20H2 x86 running JP Software 4nt, tcc, tccle.这适用于运行 JP Software 4nt、tcc、tccle 的 windows 10 v20H2 x86。 I also have implement MKS toolkit for the unix based commands我还为基于 unix 的命令实现了 MKS 工具包
ex.前任。 I use the following from the cmd prompt to create the input text raw file:我使用 cmd 提示符中的以下内容来创建输入文本原始文件:
set dr=d:\!Mp3_A-Z
echo Reading All Folders in Drive %dr...
dir/b /s %dr"\"*.mp3 > %destfolder\!geb3raw.lst
There are over 100,000 lines in the input txt file.输入 txt 文件中有超过 100,000 行。
ex: input from raw txt file例如:来自原始 txt 文件的输入
D:\!Mp3_A-Z\!AB^5117\ABBA (Rock 061619)\ABBA - Dancing Queen '128k '03_52.mp3
D:\!Mp3_A-Z\!AB^5117\!Band - RJG (Rock 061519)\Nightsoil (1972 Beckford St Tapes) 06 - Smile Away '128k '04_40.mp3
output: output:
ABBA - Dancing Queen '128k '03_52.mp3
Nightsoil (1972 Beckford St Tapes) 06 - Smile Away '128k '04_40.mp3
Try this:尝试这个:
sed 's/.*\\//' myfile.txt
This replaces everything up to and including a backslash with nothing.这将替换所有内容,包括反斜杠,什么都没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.