KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to pass 2 arguments to a command and each argument contains spaces, I've tried escaping the spaces in the args, I've tried wrapping in single quotes, I've tried escaping \" but nothing will work. Here's a simple example. #!/bin/bash -xv ARG="/tmp/a b/1.txt" ARG2="/tmp/a b/2.txt" ARG_BOTH="\"$ARG\" \"$ARG2\"" cat $ARG_BOTH I'm getting the following when it runs: ARG_BOTH="$ARG $ARG2" + ARG_BOTH='/tmp/a\ b/1.txt /tmp/a\ b/2.txt' cat $ARG_BOTH + cat '/tmp/a\' b/1.txt '/tmp/a\' b/2.txt cat: /tmp/a\: No such file or directory cat: b/1.txt: No such file or directory cat: /tmp/a\: No such file or directory cat: b/2.txt: No such file or directory
Tags (comma-separated)
Save Edits
Cancel