Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Posts
    15

    Unanswered: splitting a string

    hi,

    I have a number of filenames made up of letters and numbers like the following:

    01-000.134off.log
    01-000.14off.log
    01-000.4off.log

    What I would like to do is to strip away everything leaving just the non zero numbers ie:

    134
    14
    4

    I have managed to get this using grep and sed with no problem. What I really want to do next is split the string of numbers into single digits so that I am left being able to use the digits to place in another part of the program.

    Is this possible, I haven't been able to find the answer and I can't think of how to do it?
    thanks

  2. #2
    Join Date
    Jan 2006
    Posts
    32
    What I really want to do next is split the string of numbers into single digits
    I'm not sure what you mean by this.

    If you want the digits separated on a single line add
    Code:
    -e 's/\(.\)/\1 /g'
    to your sed statement

    If you want each digit on a separate line use
    Code:
    -e 's/\(.\)/\1^M/g'
    where you create ^M by pressing Ctrl-V, Enter.



    .

  3. #3
    Join Date
    Feb 2006
    Posts
    15
    Thank you, I had spent ages trying to work this out. The top one works just as I wanted it to!

Posting Permissions

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