|
2010-04-09
, 09:12
|
Posts: 156 |
Thanked: 90 times |
Joined on Jan 2010
|
#2
|
|
2010-04-09
, 09:16
|
Posts: 526 |
Thanked: 99 times |
Joined on Sep 2009
|
#3
|
|
2010-04-09
, 09:18
|
Posts: 3,617 |
Thanked: 2,412 times |
Joined on Nov 2009
@ Cambridge, UK
|
#4
|
lets say I have this code:
a=`hcitool scan --class | awk '/BD Address/ {print substr($3,0,8)}' | grep '00:BD:3A'`;
I'm a little unsure why the $3 field is used in the substring. I know that it's pointing to the third field but I would have though it needed the first field?
Ok so that is just for my understand, the next part is that lets say I find the code 00:BD:3A from the scan output, I then want to return the name which is the /Device name/ section of the output.
How do I this, without output the text to "table" and the filter the table buy the codes I find.
Or perhaps I am going about this the wrong way.
any help will be awesome.
a=`hcitool scan --class | awk '/BD Address/ {if (match(substr($3,0,8), "00:BD:3A") > 0) TST=1} /Device Name/ { if (TST==1) {print substr($0, 14); TST=0} }'
|
2010-04-09
, 09:23
|
Posts: 526 |
Thanked: 99 times |
Joined on Sep 2009
|
#5
|
grep '00:BD:3A\|00:BD:3B\|00:21:9E'
|
2010-04-09
, 09:35
|
Posts: 3,617 |
Thanked: 2,412 times |
Joined on Nov 2009
@ Cambridge, UK
|
#6
|
|
2010-04-09
, 09:39
|
Posts: 25 |
Thanked: 13 times |
Joined on Jan 2010
@ Bucharest, Romania
|
#7
|
Need GURU
a=`hcitool scan --class | awk '/BD Address/ {print substr($3,0,8)}' | grep '00:BD:3A'`;
I'm a little unsure why the $3 field is used in the substring. I know that it's pointing to the third field but I would have though it needed the first field?
Ok so that is just for my understand, the next part is that lets say I find the code 00:BD:3A from the scan output, I then want to return the name which is the /Device name/ section of the output.
How do I this, without output the text to "table" and the filter the table buy the codes I find.
any help will be awesome.
|
2010-04-09
, 09:42
|
Posts: 2,802 |
Thanked: 4,491 times |
Joined on Nov 2007
|
#8
|
a=`hcitool scan | sed -ne 's/^[\t]\(..:..:..\).*$/\1/' -e '/00:BD:3A/p'`
the next part is that lets say I find the code 00:BD:3A from the scan output, I then want to return the name which is the /Device name/ section of the output.
scan=`hcitool scan` a=`echo "$scan" | sed -ne 's/^[\t]\(..:..:..\).*$/\1/' -e '/00:BD:3A/p'` name=`echo "$scan" | awk "( substr(\$1,0,8) == \"$a\" ) { print \$2 }"`
|
2010-04-09
, 10:20
|
Posts: 2,802 |
Thanked: 4,491 times |
Joined on Nov 2007
|
#9
|
data=`hcitool scan | sed -ne 's/^[\t]\(..:..:..\).*[\t]\(.*\)*$/\1 \2/' -e '/00:BD:3A/p'` set -- $data a=$1 name=$2
|
2010-04-09
, 10:30
|
Posts: 526 |
Thanked: 99 times |
Joined on Sep 2009
|
#10
|
Perhaps a better alternative would be to grab all the relevant data in one go and assign it to variables afterwards:
Code:data=`hcitool scan | sed -ne 's/^[\t]\(..:..:..\).*[\t]\(.*\)*$/\1 \2/' -e '/00:BD:3A/p'` set -- $data a=$1 name=$2
I've recently starting playing around with running code in the x-term and trying to create .sh files to run scripts.
I'm working on a new script and I'm a little stuck and unsure of whats happening.
lets say I have this code:
a=`hcitool scan --class | awk '/BD Address/ {print substr($3,0,8)}' | grep '00:BD:3A'`;
I'm a little unsure why the $3 field is used in the substring. I know that it's pointing to the third field but I would have though it needed the first field?
Ok so that is just for my understand, the next part is that lets say I find the code 00:BD:3A from the scan output, I then want to return the name which is the /Device name/ section of the output.
How do I this, without output the text to "table" and the filter the table buy the codes I find.
Or perhaps I am going about this the wrong way.
any help will be awesome.
P.S the output of: hcitool scan --class looks like this:
Christopher Stobbs
My Blog