Re: Dumb Bash Script question

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/plain)
Delete this message
Reply to this message
Author: der.hans
Date:  
To: Main PLUG discussion list
Subject: Re: Dumb Bash Script question
Am 25. May, 2011 schwätzte Dazed_75 so:

> In a bash script, how can I set the contents of a variable to the result of:
>
> mount | grep tftpboot | wc | cut -c 5-8


As Kevin already pointed out, use command substitution.

numlines=$( mount | grep tftpboot | wc | cut -c 5-8 )

In this particular case, you can shorten the pipeline.

numlines=$( mount | grep -c tftpboot )

You might even be able to just get the data directly from proc.

numlines=$( grep -c tftpboot /proc/mounts )

ciao,

der.hans
-- 
#  http://www.LuftHans.com/        http://www.LuftHans.com/Classes/
#  <arclight> Delicious red tape, like a Twizzler but flat. And adhesive.
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss