2021年3月12日星期五

Bash problem: sed command to replace 'C:\Music' withe '~/Desktop/music'

Input

I have a playlist files seems

#file 1: i.m3u  C:\Users\curlywei\Music\........\a.mp3  C:\Users\curlywei\Music\........\b.mp3  
#file 2: j.m3u  C:\Users\curlywei\Music\........\x.mp3  

Above files are in the same folder.

Expect Output

#file 1: i.m3u  ~/Desktop/Music/......./a.mp3  ~/Desktop/Music/......./b.mp3  
#file 2: j.m3u  ~/Desktop/Music/......./x.mp3  

Command I do

for i in $(ls *.m3u| tr '\n' ' '); do sed 's#\#/#g' -e 's#C:/Users/curlywei/Music#~/Desktop/music#g' $i; done  

Actual result

#file 1: i.m3u  C:/Users/curlywei/Music/......../a.mp3  C:/Users/curlywei/Music/......../b.mp3  
#file 2: j.m3u  C:/Users/curlywei/Music/......../x.mp3  

Only \ is replaced with /

https://stackoverflow.com/questions/66609941/bash-problem-sed-command-to-replace-c-music-withe-desktop-music March 13, 2021 at 11:48AM

没有评论:

发表评论