Re: [Hampshire] One for sed experts

Top Page

Reply to this message
Author: Marc Loftus via Hampshire
Date:  
To: Hampshire LUG Discussion List
CC: Marc Loftus
Subject: Re: [Hampshire] One for sed experts
The problem is not the spaces, the problem is the "\" which becomes an
escape character, so sed is looking for c:usersfreditunes mediamusic

I created a test file with references in it as per your C dir example
(Called it test2)
After running an updated command to allow the back slashes to be seen:

sed -i 's^c:\\users\\fred\\itunes\\itunes
media\\music\\^x:\\anotherfolder\\^g' test2

It updated the file with the directories changed.

[marc@Surface7~]$ cat test2
c:\users\fred\itunes\itunes media\music\1.3mu
c:\users\fred\itunes\itunes media\music\2.3mu
c:\users\fred\itunes\itunes media\music\3.3mu
c:\users\fred\itunes\itunes media\music\4.3mu
[marc@Surface7~]$ sed -i 's#c:\\users\\fred\\itunes\\itunes
media\\music\\#x:\\anotherfolder\\#g' test2
[marc@Surface7~]$ cat test2
x:\anotherfolder\1.3mu
x:\anotherfolder\2.3mu
x:\anotherfolder\3.3mu
x:\anotherfolder\4.3mu

Regards

Marc

On Sat, 4 Jul 2020 at 10:56, rmluglist2--- via Hampshire <
hampshire@???> wrote:

> Hi all
>
>
>
> I’ve just moved media players (to mediamonkey from itunes). I can import
> playlists but the old ones
>
> are pointing at my previous library which I’ve now moved. I want to
> change all references to
>
>
>
> c:\users\fred\itunes\itunes media\music\
>
>
>
> to
>
>
>
> x:\anotherfolder\
>
>
>
> for every .m3u file in a given folder. I’ve made a folder that just
> contains the .m3u files by copying so , after much googling, I’ve got this:
>
>
>
> sed -i 's#c:\users\fred\itunes\itunesmedia\music\#x:\anotherfolder\#g' *
>
>
>
> but I’m getting sed: -e expression #1, char 55: unterminated `s' command
>
>
>
> I dunno whether it’s because my first string has spaces or the character
> ‘s’ but I can’t make it work. As ever (in my experience) I don’t know
> whether I’m one keystroke away or should be using awk or something similar
> like awk.
>
>
>
> Cheers
>
> Rob
>
>
> --
> Please post to: Hampshire@???
> Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
> LUG URL: http://www.hantslug.org.uk
> --------------------------------------------------------------




--
Marc Loftus | Director | WebMarcIT Ltd | 3 Annes
Way, Fleet, Hampshire, GU52 6AG | Tel 07917 568 685 | marc@???


www.webmarcit.com
Company Registered Number 08977559 | Registered in England

P Please consider the environment - do you really need to print this email?



This message is intended for the addressee only. It may contain
information of a confidential or legally privileged nature. If you have
received this message in error, please notify the sender and delete the
message immediately. WebMarcIT Ltd. cannot accept liability for any loss or
damage you may incur as a result of virus infection.
--
Please post to: Hampshire@???
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------