Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #if the number of arguments is not 1, as it should be, show USAGE message and exit.
- if [ $# -ne 1 ]
- then
- echo "USAGE: `basename $0` br_indeks"
- exit 1
- fi
- #Create a file with the given name, but delete it first if a file with that name already exists.
- if [ -f out.txt ]
- then
- rm out.txt
- fi
- touch out.txt
- #select all the rows that start with the first argument
- #leave out their 10th column only
- #substitute the each brace type with empty space as we don't need them
- #make two dots as our new internal field separator and initialize the total variable to calculate total time spent on the OS server
- #send the calculation to our newly promoted script varible user_time
- user_time=`last | grep ^$1 | awk 'print $10;' | sed -e 's/(//' -e 's/)//' | awk -F: 'BEGIN {total=0;} {total+=$1*60+$2;} END {print total;}'`
- #send user_time'z value as a text for out.txt
- echo "$user_time" >> out.txt
- #list the text in out.txt on the console
- cat out.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement