Skip to content
Advertisement

Linux piping data containing backticks

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

JavaScript

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

JavaScript

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

JavaScript

Manually adding double quotes works! like this:

JavaScript

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

JavaScript

returns:

JavaScript

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.

Advertisement

Answer

Not a direct solution the problem, but a work-around (that’s actually better, because it uses the API) in python using the python-mpd2 library:

JavaScript

I’ll accept a working solution to the actual proposed problem, instead of this one, if someone posts a working solution.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement