Mac Terminal: Edit Text Document
ls > Applications.txt
is going to list the Applications.txt
file in the list.
Though I don't entirely understand all of your workflow, adding the -d
flag should do the trick, by specifying *.app.
ls -d *.app > Applications.txt
Just like your previous approach though, that won't catch .app files buried in subdirectories (like your Adobe Suite). You can modify find's maxdepth parameter for something like that:
find . -maxdepth 1 -type d -name "*.app" > Applications.txt
If you wish to search within all subdirectories of the current one, simply omit the -maxdepth
option altogether.
If you have a problem with the pathname being part of the output (e.g., you want Terminal.app
not ./Utilities/Terminal.app
), then try this instead:
cd /Applications
find * -type d -name "*.app" -exec basename "{}" \; > Applications.txt
If you want to find any application anywhere on your Mac, try:
mdfind -interpret "kind:application" # this is localized for your language
The mdfind
command uses Spotlight's index, so it's fast, but (being an index) it may not always represent the exact, up-to-the-minute state of the filesystem. How to remove the pathname from the front is left as an exercise for the reader (hint: xargs -I{} basename "{}"
).
It might be easier to avoid the problem altogether by creating the text file outside the Applications folder. This will also make sure that the workflow works for users without write access there. In the SSH action use
cd /Applications
ls > ~/Library/Mobile\ Documents/iCloud~is~workflow~my~workflows/Documents/Applications/Applications.txt
to create the file directly at the place you want it to end up.