Here is my use case: the command line utility melt can accept a file name, with the extension .melt on the command line, and open it; as an example, this is a proper test_p.melt file:
colour:blue
out=24
colour:red
out=48
... which opens and plays with melt test_p.melt.
Now, the thing is that .melt files do not support comments, which I wish they did (you'll get error messages for any line that contains an unparsable argument, including those with, say, a #). So here is a commented test_c.melt file:
# master comment here
colour:blue # this is blue!
out=24
colour:red
out=48
Opening this in melt directly gives:
$ melt test_c.melt
Failed to load "# master comment here"
...
... and there is no blue screen shown.
So I thought - well, I can put in comments anyway, and then use Bash process substitution to filter the file with sed, and simply provide that to the melt application. First, tried a test with cat, which is successful:
$ cat <(sed 's/#.*$//' test_c.melt)
colour:blue
out=24
colour:red
out=48
... looks good; but, if I try that with melt, it sees through my trickery:
$ melt <(sed 's/#.*$//' test_c.melt)
Failed to load "/dev/fd/62"
Failed to load "/dev/fd/62"
Basically, melt got the filename of the pipe Bash provided for the process substitution - but unfortunately, what melt does is that it processes argv[i] directly; and in case of a file, it needs to see a .melt extension in the filename; if it doesn't - the process fails.
So my question is: how could I use process substitution - so the filename of the pipe has a specific extension, in this case .melt? Basically, as a result of the substitution, I'd want a pipe filename of /dev/fd/62.melt, which I think will pass.
NB: of course, I can always do:
sed 's/#.*$//' test_c.melt > test_c_temp.melt
melt test_c_temp.melt
... but first, there are two commands here - and I'd want a one-liner pipeline; and for another, it opens up another problem of me thinking about removing temporary files afterwards, which I don't like.
Is this possible with Bash process substitution - or somehow with standard Linux tools?
melt < <(sed 's/#.*$//' test_c.melt)– Costas Jan 28 '15 at 21:55meltdoesn't care about commands piped throughstdin, since I get:Usage: melt [options] [producer [name=value]* ]+and a dump of program options. Cheers! – sdaau Jan 28 '15 at 22:00man melton behalf of you. "If no files are specified, the compression is applied to the standard input*". So `sed 's/#.$//' test_c.melt | melt > result.file` can work. – Costas Jan 28 '15 at 22:07melt(MLT melt 0.6.2; "standard input" is not mentioned in this version'sman melt), since for that command, again I getUsage: melt [options] [producer [name=value]* ]+and a dump. Cheers! – sdaau Jan 28 '15 at 22:10man melton your machine. If you cannot find answer post in on http://pastebin.com and post link here. – Costas Jan 28 '15 at 22:15