Last active
October 4, 2020 12:00
-
-
Save janderudder/fc0fb718b50864063192a016340bbb52 to your computer and use it in GitHub Desktop.
lth : list a bunch of most recently modified files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -ir Entry_max=15 | |
declare -ir Max_count=$((Entry_max+1)) | |
show_listing() | |
{ | |
declare -a Entries | |
for Entry in $(\ls "$1" -1tF --color=always | head -n $Max_count) | |
do | |
Entries=(${Entries[@]} $Entry) | |
done | |
declare -i Has_more=0 | |
if [[ ${#Entries[@]} -eq $Max_count ]]; then | |
unset Entries[$Max_count] | |
Has_more=1 | |
fi | |
for Entry in ${Entries[@]} | |
do | |
echo "$Entry" | |
done | |
[[ $Has_more -eq 1 ]] && echo '...' | |
} | |
# main | |
if [[ $# -eq 0 ]]; | |
then | |
show_listing '.' | |
elif [[ $# -eq 1 ]]; | |
then | |
show_listing "$1" | |
else | |
for Target in "$@"; | |
do | |
echo "-- in '$Target'" | |
show_listing "$Target" | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment