Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] Re: line filtering (was Re: Unidentified subject!)
- Date: Wed, 07 Aug 2002 13:11:11 GMT
- From: "big0" <big0@example.com>
- Subject: [tlug] Re: line filtering (was Re: Unidentified subject!)
- References: <E17cNGT-00024b-00@example.com>
>> ------------->8----------------- >> >>gawk -F" " 'BEGIN { numexp = "[[:digit:]]+"; tmp="" } >>NR > 0 { >> if ($1 ~ numexp && tmp != "") { print tmp; tmp="" } >>} >>{ tmp = tmp" "$0; }' >> >> ------------->8----------------- > > Oh, that's gross. And it's also wrong. (Try it! It doesn't work.) It's work. But really have little mistake - do not display the last line. So with correction and in shell script: ------[ join_lines.sh ]------->8----------------- #!/bin/sh # Usage: join_lines.sh < text_file.txt # gawk -F" " ' BEGIN { numexp = "[[:digit:]]+"; tmp="" } NR > 0 { if ($1 ~ numexp && tmp != "") { print tmp; tmp="" } } { tmp = tmp" "$0 } END { if (tmp != "") print tmp; } ' ------------------------------>8----------------- And once more - do not use awk - it just do not display anything. Use gawk. Also I was wrong for mawk - it put everything on one line. The input and output test files are in the attachements. -- ISBN: 0060256575 OpenPGP: 0xBE40FF3E1 some text text with C/R s 2 and this is the second line 3 text text text 4 line number 4 and this is also line number 4 5 the last line1 some text text with C/R s 2 and this is the second line 3 text text text 4 line number 4 and this is also line number 4 5 the last line
- References:
- [tlug] line filtering (was Re: Unidentified subject!)
- From: Shimpei Yamashita
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Duplicating a MySQL database
- Next by Date: Re: [tlug] searching but don't where to look!!
- Previous by thread: [tlug] line filtering (was Re: Unidentified subject!)
- Next by thread: [tlug] Duplicating a MySQL database
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links