Home Linux piping data containing backticks
Reply: 0

Linux piping data containing backticks

user1209 Published in July 16, 2018, 3:07 am

I'm piping output from one command into a second:

mpc listall | mpc add

mpc listall returns the following data (can output 1 or more lines):

Dare - 16 - I´ll Be Your King.mp3

When piping it into the next command, it seems that my shell (Ash on BusyBox) converts the ´ into an asterisk, as I get the error

error adding Dare - 16 - I*ll Be Your King.mp3: No such directory

Manually adding double quotes works! like this:

mpc add "Dare - 16 - I´ll Be Your King.mp3"

So, I tried adding those by sed and awk, but in those cases the backtick gets converted to an asterisk again:

mpc listall | sed 's/^/"/;s/$/"/'


"Dare - 16 - I*ll Be Your King.mp3"

So, question is, is there a way to pass backticks, or actually any character, as is, into another command without conversions?

By the way, obviously, it's quite bad to have this character in the file name in the first place, but I want my code to be robust and able to handle anything thrown at it.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.323447 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO