pielgrzym
pielgrzym

Reputation: 1677

How to escape command output (oneliner) in zsh

I have this wonderful music library app: beets.

When I run beet ls somequery -f, I get a newline-separated list of my music files' paths. Unfortunately, the paths contain unescaped spaces and I can't feed mplayer like this:

mplayer `beet ls smooth`

This doesn't work either:

mplayer $((q)beet ls smooth)

Could anyone provide a compact solution?

Upvotes: 0

Views: 351

Answers (2)

Alan Curry
Alan Curry

Reputation: 14711

mplayer ${(f)"$(beet ls smooth)"}

Upvotes: 1

musiphil
musiphil

Reputation: 3847

Use xargs:

beet ls smooth | xargs mplayer

This will protect the filenames against spaces, but not newlines. (I'm assuming they don't contain newlines, as the program beet produces a newline-separated list.)

Upvotes: 1

Related Questions