Commit d3805326 authored by Simon May's avatar Simon May
Browse files

Add shell functions to get most recent file in a directory

parent 2f0f4b7e
......@@ -13,6 +13,21 @@ alias afs-auth='kinit smay@MPA-GARCHING.MPG.DE && aklog mpa-garching.mpg.de'
alias touch-r='find . -type f -exec touch "{}" +'
nth-last() {
num=1
if [ -n "$1" ]; then
num="$1"
fi
tail -"$num" | head -1
}
newest-file() {
num=1
if [ -n "$2" ]; then
num="$2"
fi
realpath -m --relative-base=. "$1"/$(ls -1rt "$1" | nth-last "$num")
}
# SLURM aliases
alias sq='squeue -o "%.8Q %.8i %16j %7u %2t %.16V %.16S %.8M %.3D %R" -S "-t,-Q,i"'
alias sq-long='squeue -o "%.8Q %.5i %63j %7u %2t %.16V %.16S %.8M %.3D %R" -S "-t,-Q,i"'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment