Find the answer to your Linux question:
Results 1 to 5 of 5
His, first time i use sed. I need to remove/delete the string "Language :" I can remove either "Language" or ":", but "Language :" doesn't work... e.g.: $ echo "Subtitles: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! clickalot's Avatar
    Join Date
    Nov 2009
    Location
    Erlangen, Germany
    Posts
    37

    [SOLVED] newbie sed question: remove Language : from string


    His,

    first time i use sed. I need to remove/delete the string "Language :"

    I can remove either "Language" or ":", but "Language :" doesn't work...
    e.g.:
    $ echo "Subtitles: Language : French,Language : English,Language : Dutch,Language : German,Language : Polish,Language : French,Language : English,Language : Dutch,Language : German,Language : Polish," | sed 's/Language ://g'

    help appreciated

  2. #2
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    848
    You need to escape the spaces:

    Code:
    echo "Language : Polish" | sed 's#Language\ :\ ##'
    Linux User #453176

  3. #3
    Just Joined! clickalot's Avatar
    Join Date
    Nov 2009
    Location
    Erlangen, Germany
    Posts
    37

    Question echo is playing tricks...

    Code:
    (...)
    ext="Audio: Language : Japanese,Language : French,Language : English,Language : German"
    
    ext=`echo "$ext" | sed 's/Language\ ://g'`
    doesn't work

    but if i substitute echo "$ext" with echo $ext, like this:
    Code:
    ext=`echo $ext | sed 's/Language\ ://g'`
    it works!

    maybe its time to call it a day

    PS: btw:
    Code:
    ext=${ext//Language\ :/}
    also doesn't work............

  4. #4
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    848
    It seems to work for me:

    Code:
    kieren@George-Michael:~$ ext="Audio: Language : Japanese,Language : French,Language : English,Language : German"
    kieren@George-Michael:~$ ext=`echo "$ext" | sed 's/Language\ ://g'`
    kieren@George-Michael:~$ echo $ext
    Audio: Japanese, French, English, German
    Linux User #453176

  5. #5
    Just Joined! clickalot's Avatar
    Join Date
    Nov 2009
    Location
    Erlangen, Germany
    Posts
    37

    Red face

    Thanks Kieren,

    i found the problem:

    my $ext had extra formating characters...

    in fact i don't need to escape the space in my case. Both
    Code:
    ext=${ext//Language :/}
    and
    Code:
    ext=`echo "$ext" | sed 's/Language ://g'`
    work just fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •