The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-15-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Maybe the second bit of output is sent to stderr instead of stdout? Try hcitool scan > addr 2>&1.

If that works, use this to get it into a variable:

Code:
addr=$(hcitool scan 3>&1 >/dev/null 2>&3 | awk '{print $1}')
The 3>&1 part copies file descriptor 1 (stdout) to a new file descriptor 3. >/dev/null discards stdout, and then 2>&3 redirects stderr to the new file descriptor. This means that the awk process which is next in the pipeline can read from stdin what would previously have gone to stderr.

Last edited by Annihilannic; 07-15-2008 at 10:19 PM.. Reason: typo