On Thu, 2010-12-09 at 11:33 -0500, Bernard Fay wrote: > Hi, > > > I have long strings to parse which have permanent and variable > information. Somewhere in the strings we have something like ".... > Handle: 0x12a7 ....". Handle is permanent and 0x12a7 is variable. I > wish to be able to extract the variable part (0x12a7) and assign it to > a variable. >
I'dd use Perl.... I love Perl.... and I don't know any other language appropriate for this :) j...@squeeje:~$ cat string.txt foo bar abc 123 Handle: 0x12a7 some more things zoo zar Handle: 0x12a7 and more stuff j...@squeeje:~$ cat string.txt | perl -e 'while (<>) {if (/Handle:\s+(\S +)/){$line++; $your_variable = $1; print "$line $your_variable\n"; }};' 1 0x12a7 2 0x12a7 > > Does anyone have an idea how to extract this information? > > > I think awk might be the tool to use but I not too good at it yet. > > > Thanks, > Bernard > > -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/1291914022.2387.31.ca...@squeeje.critical.pt