Reputation: 135
I have a bash script that contains the following text:
LOAD=`/usr/bin/w |grep "load average"`
echo $LOAD
when I execute the script it searches for load average in the files inthe directory that is given. After it's executed the output is the following:
10:06:40 up 7 days, 17:21, 3 users, load average: 0.08, 0.06, 0.09
What I want is the $LOAD variable to give the following output:
10:06:40 up 7 days, 17:21, 3 users, load averages: 0.08, 0.06, 0.09
I can't recompile the files in the directory that is given so that is not an option. Any ideas how I am able to achieve this output?
Thanks in advance
Upvotes: 0
Views: 70
Reputation: 45706
See parameter expansion. This replaces the first occurance of average
with averages
:
echo "${LOAD/average/averages}"
Upvotes: 1
Reputation: 11796
So you just want to change "average" to "averages"?
echo "$LOAD" | sed 's/average/averages/'
Upvotes: 4