Search Results

Search: Posts Made By: jack.bauer
2,175
Posted By alister
That approach would work fine if it were modified...
That approach would work fine if it were modified to use the correct number of consecutive n commands.

That sed script does not require -r.

Regards,
Alister
2,175
Posted By shamrock
Try the awk script below... awk...
Try the awk script below...
awk '/^<ClientName>foo<\/ClientName>$/,/^<\/Client>$/ {if($0 ~ "^<64bit>false</64bit>$") $0="<64bit>true</64bit>";print}' clients.xml
2,132
Posted By jim mcnamara
I don't get why you need ssh -n (-n option). But...
I don't get why you need ssh -n (-n option). But it won't affect what we are doing.
One easy way to get a status is to echo one. We use OK NOTOK


st=$(ssh me@myhost 'some command >/dev/null...
1,136
Posted By Subbeh
Is this what you're trying to do? awk...
Is this what you're trying to do?


awk -F, 'NR==1{for(i=1;i<=NF;i++)if($i==v)c=i};NR>1{print $1" "$c}' v=engine foo
1,257
Posted By Skrynesaver
awk # obviously -F, ...
awk # obviously
-F, # use comma as the field seperator
'{ # begin code to run
for(i=1;i<=NF;i++) # loop over fields in record maintaining position...
1,257
Posted By Scrutinizer
It means for every line: loop through the fields,...
It means for every line: loop through the fields, if a field matches the variable v then print the field position.

This script seems a bit strange to me, since it will just produce field numbers...
20,083
Posted By Corona688
The A[$1] before the code block: ...
The A[$1] before the code block: A[$1]{$5=A[$1];print}

nulls and blanks are considered false and won't run the code, anything else is true and will run the code block.
2,536
Posted By Scrutinizer
Yes, that is correct. Awk uses so-called...
Yes, that is correct. Awk uses so-called associative arrays..
20,083
Posted By otheus
What do you want to do with the very long SQL...
What do you want to do with the very long SQL statements? Do you want to indent them on second/third lines?

BTW: This is what perl was designed for:

#!/usr/bin/perl
format =
@###### ...
2,536
Posted By Scrutinizer
When FNR==NR (the first file is being read), load...
When FNR==NR (the first file is being read), load field 2 ($2) into array with index of field 1 ($1), until FNR!=NR then the second file starts (and the first section of the script is now skipped)....
2,536
Posted By Scrutinizer
Ok, since you already used arr[$1] to create an...
Ok, since you already used arr[$1] to create an empty array element with the index of field 1, I used that to give it the value of field 2 instead, which then later gets referenced in the second...
2,536
Posted By Scrutinizer
Try: awk -F, 'FNR==NR {arr[$1]=$2; next} $3 in...
Try:
awk -F, 'FNR==NR {arr[$1]=$2; next} $3 in arr {print $2,$4,$5,arr[$3]}' OFS=, file1 file2
4,817
Posted By Scrutinizer
I noticed and I adjusted my response as well :)
I noticed and I adjusted my response as well :)
4,817
Posted By Scrutinizer
Welcome to the forum! You can use the inverse:...
Welcome to the forum!
You can use the inverse:
awk 'FILENAME=="target" {arr[$0]++}
FILENAME=="lookup" {if(!($0 in arr)) {print $0}}' target lookup
8,929
Posted By Scrutinizer
Try: awk -F, '{for(i=1;i<=NF;i++)A[$i]=i;print...
Try:
awk -F, '{for(i=1;i<=NF;i++)A[$i]=i;print "The field "v" is on position "A[v];delete A}' v=IDENTIFIER infile
or without arrays:
awk -F, '{for(i=1;i<=NF;i++)if($i==v)print "The field "v" is on...
Showing results 1 to 15 of 15

 
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy