9

Let's say there is one script s1, and I need to pass argument $1 with value foo bar, with space in it. This can be done

./s1 "foo bar"

however, when I want to run the above command in another script (say s2), how should I put it? If I put it as above, foo bar will be interpreted as two arguments (to s1) rather than one.

3 Answers 3

17

You can try quoting $1:

./s2 "$1"
Sign up to request clarification or add additional context in comments.

2 Comments

do you mind explaining what would s2 looks like? I don't need to pass argument to s2, but to s1.
@Richard I'm not quite sure what you are asking. Can you clarify ?
1

Use single quotes.

./script 'this is a line'

To consider variable substitutions use double quotes

./script "this is a line"

Comments

-4

How about:

./s1 foo\ bar

Would that work?

1 Comment

Thanks for the suggestion. I did not have sufficient reputation to have the ability to make a comment on this post. I will keep this in mind next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.