Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Liste formatieren

0 views
Skip to first unread message

David Mann

unread,
Sep 17, 2008, 1:14:58 PM9/17/08
to
Hallo,

ich habe hier eine Datei dieser Form:

wort1
wort2
wort3
usw.

und möchte sie in eine solche transformieren:

"wort1|wort2|wort3|usw."

Wie geht das am einfachsten?

Danke,
David

Alexander Bartolich

unread,
Sep 17, 2008, 1:31:35 PM9/17/08
to
David Mann schrieb:

tr '\n' '|' < Datei

--
usingwhitespaceisracism

Reinhard Skarbal

unread,
Sep 17, 2008, 1:59:07 PM9/17/08
to
"David Mann" <m...@privacy.net> schrieb im Newsbeitrag
news:48d13b10$0$13385$6e1e...@read.cnntp.org...
awk '{printf "%s|",$0}END{printf ""}' DeinFile > Einzeiler

lG,
Reinhard


Michael Schmarck

unread,
Sep 18, 2008, 1:11:33 AM9/18/08
to
David Mann <m...@privacy.net> wrote:

Ich helfe mir in aller Regel mit einer Schleife:

while read zeile; do
printf '%s|' "$zeile"
done < datei
printf '\n'

Michael

David Haller

unread,
Sep 17, 2008, 8:40:33 PM9/17/08
to
Reinhard Skarbal <reinhard...@aon.at> wrote:
> "David Mann" <m...@privacy.net> schrieb im Newsbeitrag
> news:48d13b10$0$13385$6e1e...@read.cnntp.org...
>> ich habe hier eine Datei dieser Form:
>>
>> wort1
>> wort2
>> wort3
>> usw.
>>
>> und m?chte sie in eine solche transformieren:
>>
>> "wort1|wort2|wort3|usw."
>>

> awk '{printf "%s|",$0}END{printf ""}' DeinFile > Einzeiler

awk '{print;}' ORS="|" DeinFile > Einzeiler

-dnh

--
panic("ocfs2 is very sorry to be fencing this system by panicing\n");
-- /usr/src/linux/fs/ocfs2/cluster/quorum.c

0 new messages