Following command prints the path of the song being played.
mpc | head -n 1
songs/oldSongs/Mukesh_D/041 KANHAIYA = YAAD AAYI ADHI RAAT KO.mp3
Can I delete this file by modifying the command I used to print it?
|
Following command prints the path of the song being played.
Can I delete this file by modifying the command I used to print it? |
|||
|
|
|
To answer your more general question, that's the job of However, If the input is a newline-terminated list, the canonical way to convert it to the format expected by xargs is to escape every character (though only, backslash, single quote, double quote, underscore (potentially), space and tab are necessary) but newline with a backslash character, which we can do with sed.
Note that some With GNU
(also using the GNU specific -r option to avoid running any command if the input is empty). |
|||||
|
|
You can do this with |
|||||||
|
|
Unless you are able to produce NULL-terminated filenames (as e.g.
The advantage is, that you can pretty much arbitrarily transform the output (e.g. when you decide not to rename rather than to delete or when you need to strip parts of the output). |
|||
|
|
|
If it's safe to assume you do not have files with double quotes or newlines you can do:
The sed adds quotes around your file name, and xargs turns the input it gets to arguments for the command it is running (in this case, the rm command). |
|||
|
|