Skip to content

Commit 127b399

Browse files
authored
Merge pull request #19 from sayz/patch-1
do more human readable
2 parents 2ed807a + 1123dd2 commit 127b399

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

recipes/Bash/576876_awk_sample/recipe-576876.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
file=${1:?"file?"}
3+
FILE=${1:?"FILE?"}
44

55
echo $*
66
#get the fields
@@ -9,10 +9,10 @@ echo $*
99
#print the fields
1010

1111
#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" }\
1616
{split($3, real, ":"); $3=real[1]*60 + real[2]} \
1717
#{printf $1 "\t"$2 "\t" $3"\n"} \
1818
{ user_sum += $1; sys_sum += $2; real_sum += $3; count++} \

0 commit comments

Comments
 (0)