Check These Out
Friday is the 5th day of the week, monday is the 1st.
Output may be affected by locale.
Finder compresses to ZIP but always includes extraneous metadata files (__MACOSX and .DS_Store) files and folders that may confuse other programs.
One alternative is creating them and then editing the ZIP. This can work standalone or in an automator script accepting multiple selections (files or folders) and creating one zip per argument/selected file without that metada.
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"
}
Found this little gem here: http://info.michael-simons.eu/2008/10/25/recursively-md5sum-all-files-in-a-directory-tree/
Rather than complicated and fragile paths relative to a script like "../../other", this command will retrieve the full path of the file's repository head. Safe with spaces in directory names. Works within a symlinked directory. Broken down:
$cd "$(dirname "${BASH_SOURCE[0]}")"
temporarily changes directories within this expansion. Double quoted "$(dirname" and ")" with unquoted ${BASH_SOURCE[0]} allows spaces in the path.
$git rev-parse --show-toplevel
gets the full path of the repository head of the current working directory, which was temporarily changed by the "cd".
Parallel is from https://savannah.nongnu.org/projects/parallel/
Other examples would be:
(echo foss.org.my; echo www.debian.org; echo www.freenetproject.org) | parallel traceroute
seq -f %04g 0 9999 | parallel -X rm pict{}.jpg
GNU Sed can 'address' between two regex, but it continues parsing through to the end of the file. This slight alteration causes it to terminate reading the input file once the STOP match is made.
In my example I have included an extra '/START/d' as my 'start' marker line contains the 'stop' string (I'm extracting data between 'resets' and using the time stamp as the 'start').
My previous coding using grep is slightly faster near the end of the file, but overall (extracting all the reset cycles in turn) the new SED method is quicker and a lot neater.
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"
}