BASH: troubke using a function argument passed to awk to find major
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > BASH: troubke using a function argument passed to awk to find major




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    BASH: troubke using a function argument passed to awk to find major  
Ho-Kuo Chan


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-15-05 11:05 PM

Hi,
I am a relative newbie to BASH programming but I've read and learned a
lot but I can't seem to solve my problem. I am trying to figure out the
major number of a device through cat /proc/devices piped to awk:

cat /proc/devices | awk '/theDeviceName/ { printf $1 }'.

I am trying to write a function that receives the device name as an
argument:

function find_major()
{
MAJOR=`cat /proc/devices | awk '/$1/ { printf $1 }'`

# do some other work...
}

I have tried this:
function find_major()
{
MAJOR=`cat /proc/devices | awk '/$1/ { printf \$1 }'`

# do some other work...
}

and some other alternatives but just can't seem to get it to work. Can
anyone help?

Thanks in advance!!

HK





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:50 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register