1

Ubuntu, terminal window, bash shell:

alex@d120432:~$ echo $0
bash
alex@d120432:~$ echo $(perl -e 'print "a"x2')
aa
alex@d120432:~$ i=2
echo $i
2
alex@d120432:~$ echo $(perl -e 'print "a"x$i')

alex@d120432:~$

Is there syntax which allows to substitute $i with 2, so that the second echo command prints xx like the first one?

1 Answer 1

1

You need to get quoting right:

i=2
perl -le "print 'a' x $i"

aa
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I found that my case is more complicated, can you see this question? stackoverflow.com/questions/60074869/…

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.