Find the answer to your Linux question:
Results 1 to 3 of 3
I have a script that I can run on my movie subtitles and fix the most common errors in subtitles. for this I have been using sed commands (the most ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    Location
    City of Salt
    Posts
    185

    Help with sed commands


    I have a script that I can run on my movie subtitles and fix the most common errors in subtitles. for this I have been using sed commands (the most common error that I have seen is using a lower case L when an upper case i should have been used). I have fixed all of these so it will clean them up real nice. One thing I am running into now is numbers. Sometimes there is a space between numbers and I would like to remove the space. This is what I tried to use:
    Code:
    sed 's/[0-9] [0-9]/[0-9][0-9]/g'
    Thinking that would get rid of the space. What it did was much worse.

    This is what the original looked like
    Code:
    140
    00:08:19,081 --> 00:08:20,999
    He did my first suit when I was 1 5.
    and this is what the script did to it.
    Code:
    140
    00:08:19,081 --> 00:08:20,999
    He did my first suit when I was [0-9][0-9].
    Any thoughts?

  2. #2
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    224
    hi,

    Code:
    sed 's/\([0-9]\) \([0-9]\)/\1\2/g
    [0-9] is a range pattern.
    patterns are only interpreted on the left hand side of a sed command.

  3. #3
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    Location
    City of Salt
    Posts
    185
    Quote Originally Posted by watael View Post
    hi,

    Code:
    sed 's/\([0-9]\) \([0-9]\)/\1\2/g
    [0-9] is a range pattern.
    patterns are only interpreted on the left hand side of a sed command.

    You are awesome, this worked great.

    Thank you.

Posting Permissions

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