How to seperate text/numbers?

How to seperate text/numbers?

Post by Charlie Gib » Wed, 27 Apr 1994 11:13:03




Quote:(Joergen Hjort) writes:
>I have a file which contains some information I'm interested in!
>I use 'grep' to get each line.

>Now I have a string/line looking something like this

"Some.texts.here.1224"

Quote:>The question is, how do I get rid of that number?
>Note: the '.' is always in front of the number - and I don't want the last
'.'
>either, only the first ones.

Try using awk.  Here's a little program that should be pretty close
to what you're after:

BEGIN { FS = "." }
{
    for (i = 1; i < NF; i++) {
        printf "%s", $i
        if (i < (NF - 1))
            printf "."
    }
    printf "\n"

Quote:}

I tried this with the following test file:

Some.texts.here.1224
abc.0001
123.456.789
.foo
bar
This line has .spaces .and. periods
This line has .a. trailing.period.

...and here's what came out...

Some.texts.here
abc
123.456

This line has .spaces .and
This line has .a. trailing.period

Hope this helps...


If your nose runs and your feet smell, you're built upside-down.

 
 
 

1. How to seperate text/numbers?

I have a file which contains some information I'm interested in!
I use 'grep' to get each line.

Now I have a string/line looking something like this "Some.texts.here.1224"
The question is, how do I get rid of that number?
Note: the '.' is always in front of the number - and I don't want the last '.'
either, only the first ones.

Thanks.
Joergen

2. Need good LPD - Program that works with SCO

3. tools to seperate one large text file into two small text files?

4. EIDE... 4 Hard Drives...

5. Numbering a text file (UNIX 'number' command)

6. Adduser: Command not found. But it's there!

7. SBU/Networker Multiple Jukeboxes

8. seperate login schemes for seperate users

9. comma seperated, quoted text data

10. to seperate between number and alphabet characters

11. Number Nine....Number Nine....Number Nine