-1

I'm looking for one command that find path and open all of .app with only change app name in Terminal.

I tried :

mdfind "calendar.app" "kind:app" | grep -v '/Users/' | xargs open 

Work well with calendar, safari, calculator --> find and open .app

But when i tried .app with space, it doesn't work:

mdfind "Google Chrome.app" "kind:app" | grep -v '/Users/' | xargs open 

The files /Applications/Google and /Users/Simon/Chrome.app do not exist.

I tried with -0, \ but not work

Can u help me?

ΔO 'delta zero'
  • 3,506
  • 1
  • 19
  • 31
Vitiligo
  • 5
  • 1
  • Please [edit] your question title to something that describes the actual problem you're having or question you're asking. Your current title just echoes information already available in the tags and provides no useful information. Your title should be clear and descriptive enough to be useful to a future site user who is scanning through a list of search results trying to find a solution to their problem, and your current title does not do so. Thanks. – Ken White Dec 31 '20 at 01:31

1 Answers1

0

As mdfind returns /Applications/Google Chrome.app, a name containing a space, you need to wrap it in quotes before you pass it to xargs.

mdfind "Google Chrome.app" "kind:app" | grep -v '/Users/' | awk '{print "\x27" $0 "\x27" }' | xargs open

Like this, awk will print a single quote (\x27) before and after the string, resulting in: '/Applications/Google Chrome.app'. Now, xargs will understand this input properly.

ΔO 'delta zero'
  • 3,506
  • 1
  • 19
  • 31