hi
any bash guru in the list? i am porting the make-live-device to python and i have problems with this line of code
BLKID = `blkid | grep ${2}1 | awk '{ for(i=1;i<NF;i++) { if( $i ~ "UUID" ) { print $i } }
if anyone could break it into chunks or pseudocode for me it would be really helpful...
thanks
enrike
On Thu, 3 Jun 2010, enrike wrote:
BLKID = `blkid | grep ${2}1 | awk '{ for(i=1;i<NF;i++) { if( $i ~ "UUID" ) { print $i } } if anyone could break it into chunks or pseudocode for me it would be really helpful...
it's missing a final ' for awk and a final ` for the value to assign to BLKID.
it looks for the value of $2, followed by a "1" character, in the output of BLKID, then it looks for a field that contains the letters UUID. The field number ($i) is then assigned to the BLKID variable. Field numbers start at 1. Delimiters are any sequence of spaces and tabs. If a delimiter begins a line, the delimiter is ignored. NF is the number of fields and thus the for-loop should say i<=NF because i<NF would skip the last field.
what do you need to know ?
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801
damm! i sent the mail to the wrong list! it was meant for puredyne list and not for puredata...
thanks anyway mathieu
og., 2010.eko ekaren 03a 21:33(e)an, Mathieu Bouchard(e)k idatzi zuen:
On Thu, 3 Jun 2010, enrike wrote:
BLKID = `blkid | grep ${2}1 | awk '{ for(i=1;i<NF;i++) { if( $i ~ "UUID" ) { print $i } } if anyone could break it into chunks or pseudocode for me it would be really helpful...
it's missing a final ' for awk and a final ` for the value to assign to BLKID.
it looks for the value of $2, followed by a "1" character, in the output of BLKID, then it looks for a field that contains the letters UUID. The field number ($i) is then assigned to the BLKID variable. Field numbers start at 1. Delimiters are any sequence of spaces and tabs. If a delimiter begins a line, the delimiter is ignored. NF is the number of fields and thus the for-loop should say i<=NF because i<NF would skip the last field.
what do you need to know ?
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801