Reputation: 4113
Julia is ignoring quotes when I use run(), e.g.:
run(`cat file.txt | sed "s/blah/hi/"`)
ignores the quotes, which are required.
\"
does not work...
EDIT: The error is with the pipeline:
cat: |: No such file or directory
cat: sed: No such file or directory
cat: s/blah/hi/: No such file or directory
ERROR: failed process: Process(`cat file.txt | sed s/blah/hi/`, ProcessExited(1)) [1]
in pipeline_error at process.jl:502
in run at ./process.jl:479
Upvotes: 1
Views: 285
Reputation: 33290
The |
does not create a pipe inside of Julia backtick syntax. Instead, you are invoking the cat
program with four arguments:
file.txt
|
sed
s/blah/hi/
Since these files are unlikely to all exist, cat
terminates with an error. Note that sed
does not require quotes around the last argument. In fact, if it did get quotes then it wouldn't do what you want at all since the program would be a single string literal. It's the shell that sees the double quotes and passes their contents to sed
as a single argument. In this case, since there are no spaces or other characters that are special to most shells between the quotes, it makes no difference. To accomplish what you want you can do this:
run(`cat file.txt` |> `sed "s/blah/hi/"`)
The double quotes are optional as they are in the shell since there are no spaces or other special characters inside of the argument to sed
.
Upvotes: 5