File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
recipes/Bash/576876_awk_sample Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /usr/ bin/env bash
2
2
3
- file =${1:? " file ?" }
3
+ FILE =${1:? " FILE ?" }
4
4
5
5
echo $*
6
6
# get the fields
@@ -9,10 +9,10 @@ echo $*
9
9
# print the fields
10
10
11
11
# awk 'BEGIN { FS = "\n"; RS = "" }\
12
- #{print $2 }' $file \
13
- sed -n ' /.* user.* system.* /p' $file \
14
- |sed -e ' s/user//' -e ' s/system//' -e ' s/elapsed//' |\
15
- awk ' BEGIN { FS = " " ; RS = " \n" }\
12
+ #{print $2 }' $FILE \
13
+ $(which sed) -n ' /.* user.* system.* /p' ${FILE} \
14
+ |$(which sed) -e ' s/user//' -e ' s/system//' -e ' s/elapsed//' |\
15
+ $(which awk) ' BEGIN { FS = " " ; RS = " \n" }\
16
16
{split($3 , real, " :" ); $3 =real[1]* 60 + real[2]} \
17
17
#{printf $1 " \t" $2 " \t" $3 " \n" } \
18
18
{ user_sum += $1 ; sys_sum += $2 ; real_sum += $3 ; count++} \
You can’t perform that action at this time.
0 commit comments