Take arguments of console command from file
It's possible to use the contents from a file and not the file itself how arguments of a console command?
Thanks |
It's possible, but depends on the contents of the file. If the only thing in the file are arguments you want to use, then you can do this:
command `cat filename` Those are backticks ( ` ) not single quotes ( ' ). The shell will repace the backticks with the output of the command inside the backticks. |
Thanks, but now I have another problem. If some of the arguments are filenames with spaces? Now it interpretes every word like an argument.
When working with such filenames normally I quote them or use "\ ", perhaps there is some other way using "\<ASCII code>" or something that doesn't uses spaces? |
Then you would need to add the escape sequences in the file itself, or surround the filenames with double quotes. Such as:
Code:
/path/to/some\ file Code:
"/path/to/some file" |
Doesn't work, gives:
Code:
/path/to/some\ : No such file or directory Code:
"/path/to/some : No such file or directory |
Ugh... my mistake... I should have tested it before opening my mouth. That's a bit odd though. To my knowledge, the shell should have interpreted that text exactly as if it had been typed at a prompt.
I couldn't get things to work with a number of different gyrations I tried on my own. You may have to use a small shell script. |
All times are GMT -5. The time now is 02:36 PM. |