Re: need help with awk
- From: Kumar Appaiah <a.kumar@xxxxxxxxxxxxxxxxx>
- Date: Tue, 6 Oct 2009 09:59:52 -0500
On Tue, Oct 06, 2009 at 04:41:43PM +0200, Guillaume CHARDIN wrote:
Hi,
In a backup process of some xen virtual machine, i need to extract in
the config file some informations (in fact the disk line) .
The line look like this :
disk = [ file:/path/to/file,sda1,w ]
my goal is to isolate le `file` part to use it later. I'm a beginner
with sed/grep and i dont know it its possible to just extract the part
between two given regexp. With awk its possible to extract LINES from
a file with this syntax `awk "/firstFoundRegexp/,/secondRegexp/"`
this kind of behavior can be applied on one file ?
To extract the file name:
echo disk = [ file:/path/to/file,sda1,w ]|awk 'BEGIN { FS = "[/,]"; } { print $4}'
As for processing only between some lines, you can try this:
<code>
BEGIN { proces_line = 0; }
/startprocessing_regexp/ { process_line = 1 }
process_line {
/* Do stuff */
}
/stopprocessing_regexp/ { process_line = 1; }
</code>
Far from elegant, but will work (I think).
HTH.
Kumar
--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
- Follow-Ups:
- Re: need help with awk
- From: Guillaume CHARDIN
- Re: need help with awk
- References:
- need help with awk
- From: Guillaume CHARDIN
- need help with awk
- Prev by Date: need help with awk
- Next by Date: Re: [ANNOUNCE] apt-offline 0.9.3 released
- Previous by thread: need help with awk
- Next by thread: Re: need help with awk
- Index(es):
Relevant Pages
|