简体   繁体   中英

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.

I would like to implement this from a Unix command line and put it into a shell script. This is for windows 10 v20H2 x86 running JP Software 4nt, tcc, tccle. I also have implement MKS toolkit for the unix based commands

ex. I use the following from the cmd prompt to create the input text raw file:

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.

ex: input from raw txt file

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM