Re: SED: Insert Token at specific points
From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 06/30/05
- Next message: Sven Mascheck: "Re: how to write portable shell scripts?"
- Previous message: Sven Mascheck: "Re: how to write portable shell scripts?"
- In reply to: Thorsten Knopel: "SED: Insert Token at specific points"
- Next in thread: Alan Connor: "Re: SED: Insert Token at specific points"
- Reply: Alan Connor: "Re: SED: Insert Token at specific points"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Jun 2005 10:38:39 GMT
On comp.unix.shell, in <42C3BDDB.90304@gmx.de>, "Thorsten Knopel" wrote:
>
>
> Hello
>
> I hada little problem
>
> we Data (CSV) files with following schema
>
> DATA "Karl" "2" "OLGA" "4" "5" "6" "TOTO" ... "70"
> DATA "1" "MEL" "URGA" "4" "SEPP" "6" "TOT" ... "70"
>
>
> And we want insert empty values at position 3 and 5
>
> DATA "Karl" "2" "OLGA" "" "4" "5" "" "6" "TOTO" ... "70"
> DATA "1" "MEL" "URGA" "" "4" "SEPP" "" "6" "TOT"... "70"
sed -n 's/^\(DATA \)\(\"[^"]*\"\)\( \"[^"]*\" \)\(\"[^"]*\"\)\
\( \"[^"]*\" \)\(\"[^"]*\"\)\ \(.*\)/\1\2 \3 \"\" \5 \"\" \
\7/p' inputfile > outputfile
# copy the above literally, making sure there is a newline
# immedialtely after the final "\" on each line.
mv outputfile inputfile # AFTER testing carefully!
I think that'll do the job. If not, a little playing with it will
make it work.
>
> A simple patter didnt do a ,because we have lines of 50 to 70
> Values, and the pattern will be to big.
>
> How we can do this simply with a sed script ?
>
>
> Thanks for you Help
>
Sure,
AC
- Next message: Sven Mascheck: "Re: how to write portable shell scripts?"
- Previous message: Sven Mascheck: "Re: how to write portable shell scripts?"
- In reply to: Thorsten Knopel: "SED: Insert Token at specific points"
- Next in thread: Alan Connor: "Re: SED: Insert Token at specific points"
- Reply: Alan Connor: "Re: SED: Insert Token at specific points"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|