Last active
January 30, 2019 09:51
-
-
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
This file contains 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
# 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 |
This file contains 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
tmpfile=$(mktemp /tmp/dirnames.XXX) && for i in $( ls . ); do ls -A $i >> $tmpfile; done && sort < $tmpfile | uniq && unlink $tmpfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.