|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a file with a pattern that repeats throughout the file:
LABEL text text text text text text text text LABEL more text (where LABEL is identical throughout the file) and need to parse it so that it produces everything after each instance of LABEL (delimited by the next instance of a label) on 1 line : i.e. LABEL text text text text text text text text LABEL more text etc etc Thanks in advance |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Wed, 06 Dec 2006 20:53:25 GMT, banzai
<banzai@aa.com> wrote: > I have a file with a pattern that repeats throughout the file: > > LABEL text text > text text text > text text text > LABEL > more text > > (where LABEL is identical throughout the file) > > and need to parse it so that it produces everything after each instance of > LABEL (delimited by the next instance of a label) on 1 line : > > i.e. > > LABEL text text text text text text text text > LABEL more text > > etc etc > > Thanks in advance > awk '/^LABEL/{print ""}{printf "%s ",$0} END{print ""}' -- Don't make a big deal out of everything; just deal with everything. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
banzai wrote:
> I have a file with a pattern that repeats throughout the file: > > LABEL text text > text text text > text text text > LABEL > more text > > (where LABEL is identical throughout the file) > > and need to parse it so that it produces everything after each instance of > LABEL (delimited by the next instance of a label) or by the end of the file apparently > on 1 line : > > i.e. > > LABEL text text text text text text text text > LABEL more text > awk -v RS="LABEL" 'NR>1{$1=$1 rint RS,$0}' fileEd. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"Bill Marcum" <bmarcum@iglou.com> wrote in message news:qaqj44-gl3.ln1@don.localnet... > On Wed, 06 Dec 2006 20:53:25 GMT, banzai > <banzai@aa.com> wrote: >> I have a file with a pattern that repeats throughout the file: >> >> LABEL text text >> text text text >> text text text >> LABEL >> more text >> >> (where LABEL is identical throughout the file) >> >> and need to parse it so that it produces everything after each instance >> of >> LABEL (delimited by the next instance of a label) on 1 line : >> >> i.e. >> >> LABEL text text text text text text text text >> LABEL more text >> >> etc etc >> >> Thanks in advance >> > awk '/^LABEL/{print ""}{printf "%s ",$0} END{print ""}' > > > -- > Don't make a big deal out of everything; just deal with everything. thanks |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
banzai <banzai@aa.com> wrote:
> I have a file with a pattern that repeats throughout the file: > > LABEL text text > text text text > text text text > LABEL > more text > > (where LABEL is identical throughout the file) > > and need to parse it so that it produces everything after each instance of > LABEL (delimited by the next instance of a label) on 1 line : > > i.e. > > LABEL text text text text text text text text > LABEL more text > > etc etc > > Thanks in advance 1. Put LABEL in its own line, using 'tr', 'sed', whatever 2. Then, you have nice line range to work with. Use 'tr' to collapse the lines and whitespaces. If you're adventurous, then you can try my C extensions to Bash. strcpy all < file for i in ${all|,LABEL}; do echo "LABEL ${i|.strip}" done See my .sig below. -- William Park <opengeometry@yahoo.ca>, Toronto, Canada ThinFlash: Linux thin-client on USB key (flash) drive http://home.eol.ca/~parkw/thinflash.html BashDiff: Super Bash shell http://freshmeat.net/projects/bashdiff/ |
|
![]() |
| Outils de la discussion | |
|
|