Skip to content

Instantly share code, notes, and snippets.

@settermjd
Last active January 30, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save settermjd/5c15e1d1683d3f75d077349adaee9718 to your computer and use it in GitHub Desktop.
Save settermjd/5c15e1d1683d3f75d077349adaee9718 to your computer and use it in GitHub Desktop.
Bash one-liner to print a list of unique names in ownCloud apps
# Create a temporary file to store the results of the script
tmpfile=$(mktemp /tmp/dirnames.XXX);
# Print the directories found in each app directory
for i in $( ls . )
do
ls -A $i >> $tmpfile
done
# Sort and print a unique list of the discovered directories
sort < $tmpfile | uniq
# Remove the temp file after use
unlink $tmpfile
tmpfile=$(mktemp /tmp/dirnames.XXX) && for i in $( ls . ); do ls -A $i >> $tmpfile; done && sort < $tmpfile | uniq && unlink $tmpfile
@settermjd
Copy link
Author

settermjd commented Jan 30, 2019

Recently, I've been updating a section of the ownCloud developer tutorial, and needed to find a unique list of the names of directories that are commonly available for ownCloud apps. This bash one-liner almost did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment