I have a text file (test.txt) whose contents are:
mplayer -fs video.avi -vf mirror
If I execute:
eval "$(cat test.txt)"
I get:
doesn't exist.or
Error parsing option on the command line: -vf
MPlayer 1.1-4.8 (C) 2000-2012 MPlayer Team
But if I execute:
mplayer -fs video.avi -vf mirror
the video will be played.
Why does eval
(or mplayer
?) fail in this case?
I ran:
$ file test.txt
test.txt: ASCII text, with CRLF line terminators
The text file seems to be created under Windows. I copied its contents and created a new file under Linux. Now it works.
But how to get it working with the original Windows file? Do I have to replace some characters?
Just use
tr
to strip off the windowsCRLF
file endings and convert it toUNIX
line termination stringsTo run your original command in with the above logic invoke an explicit sub-shell with the
-c
flag,