Skip to content

Instantly share code, notes, and snippets.

@constvoidblog
Last active June 29, 2018 18:37
Show Gist options
  • Save constvoidblog/53209519abbbfb8ab58382849ef044cf to your computer and use it in GitHub Desktop.
Save constvoidblog/53209519abbbfb8ab58382849ef044cf to your computer and use it in GitHub Desktop.
lftp bookmark wrapper for listing files on a nas
#!/bin/bash
#suppose we have a NAS bookmarked as music w/audio stored in "artist/album" format:
# ls_nas.sh music #list all artists
# ls_nas.sh music L #list all arists starting w/L
# ls_nas.sh music L*/ #list all albums of artists starting w/L
if [[ "$#" < 1 ]]; then
echo "ls_nas.sh <bookmark> [glob]"
echo " "
echo "Bookmarks:"
lftp -e "bookmark list; quit"
exit 1
fi
bookmark=$1
glob="*"
if [[ "$#" >1 ]]; then
glob="$(echo $2 | sed 's/ /\\ /g')*"
fi
lftp ${bookmark} -e "cls -1d ${glob}; quit" | sed 's/^.* \///g' | column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment