Check These Out
This command can be set as an alias in ~/.bashrc
For example (in my case) I have :
alias watchDl='while [ "$(ls $filePart)" != "" ]; do sleep 5; done; mpg123 /home/.../warning.mp3" '
Then I just need to
- initialize filePart (e.g. filePart="*bigFile*rar.part")
- launch watchDl
That goes into your $HOME/.exrc file.
" Nice macro to reformat lines:
map ^A !}fmt
Note that the ^A has to be input by typing ^V^A.
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
Sometimes in a hurry you may move or copy a file using an already existent file name. If you aliased the cp and mv command with the -i option you are prompted for a confirmation before overwriting but if your aliases aren't there you will loose the target file!
The -b option will force the mv command to check if the destination file already exists and if it is already there a backup copy with an ending ~ is created.
Using this command you can track a moment when usb device was attached.
Sometimes I need to create a directory of files to operate on to test out some commandlinefu I am cooking up. The main thing is the range ({1..N}) expansion.
This is my first attempt at converting all HTML files to UTF-8 file encoding, including all subfolders.
Theres probably a much more compact way to do it, but I'm quite proud of it with my windows background ;)
Another way of counting the line output of tail over 10s not requiring pv.
Cut to have the average per second rate :
tail -n0 -f access.log>/tmp/tmp.log & sleep 10; kill $! ; wc -l /tmp/tmp.log | cut -c-2
You can also enclose it in a loop and send stderr to /dev/null :
while true; do tail -n0 -f access.log>/tmp/tmp.log & sleep 2; kill $! ; wc -l /tmp/tmp.log | cut -c-2; done 2>/dev/null