new to osx - alter multiple files at once?

Discussion in 'Mac Programming' started by BabaG, Aug 4, 2008.

  1. BabaG macrumors member

    Joined:
    Jan 5, 2007
    #1
    could someone straighten out this line?

    find /Users/babag/Documents/m3u/for_sed_tests -name "*.m3u" | xargs perl -pi -e 's/home\/babag\/mnt\/SAMBA/\/Volumes\/g'

    not a programmer, here, but have done some scripting in linux and
    windows.

    i have a lot of text files, m3u files to be specific, that i'd like to alter
    a path line in. the original path is:

    /home/babag/mnt/SAMBA/homeserver/Data-1_max80/CDs/FLAC

    i'd like to change it to read:

    /Volumes/homeserver/Data-1_max80/CDs/FLAC

    when i used the line above, it produces this error:

    Substitution replacement not terminated at -e line 1.

    how do i get the line to work and alter all my files as described?

    thanks,
    BabaG
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    I don't know if that, in perl, will replace text in a file like sed.

    However, there is an issue with your substitution command:
    s/home\/babag\/mnt\/SAMBA/\/Volumes\/g

    broken down, we have:
    s/
    home\/babag\/mnt\/SAMBA
    /
    \/Volumes\/g

    I think to get the replacement command you want, the last / should not be escaped with \. So instead, you would have:
    s/home\/babag\/mnt\/SAMBA/\/Volumes/g

    -Lee
     

Share This Page