Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #almost the same as the auditorium one
- if [ $# -ne 3 ]
- then
- echo "USAGE: `basename $0` index month day"
- exit 1
- fi
- INDEX=$1
- MONTH=$2
- DAY=$3
- #just like grep, with sed /p with can print the lines that contain the ceratin string with -n meaning printing only the lines of interest
- time_logged_in=`last | grep ^$INDEX | sed -n '/$MONTH *$DAY /p' | awk 'print $10' | sed -e 's/(//' -e 's/)//' | awk -F: 'BEGIN {time=0} {time+=60*$1+$2} END {print time}' `
- if [ -d loggedin.txt ]
- then
- rm loggedin.txt
- fi
- touch loggedin.txt
- echo "$time_logged_in" >> loggedin.txt
- cat loggedin.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement