Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] sed or awk or what?



>>>>> "JI" == Jean-Christian Imbeault <jean_christian@example.com> writes:

    >> From: Sven Simon <sven@example.com>

    >> I have a file where I'd like to change the 9th field on the
    >> second line to, say, 70. Field seperator is space. I would

    JI> how about:

    JI> s/(.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*)(.*) /\1 \2 \3
    JI> \4 \5 \6 \7 \8 70\10

A bit shorter (the first line prints three lines of numbers)

$ for i in `seq 1 3`; do seq -s ' ' 30 10 120; done |
perl -pe '$.==2 && s/((\S+\s){8})(\S+)/${1}70/'
30 40 50 60 70 80 90 100 110 120
30 40 50 60 70 80 90 100 70 120
30 40 50 60 70 80 90 100 110 120

Viktor

P.S. Sorry about the stupid mail I sent earlier about the s modifier.
(Mr. Listmaster, can we erase it from the archives?:) It was the case
when the mind clears next moment after the message has been sent...


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links