I have bash script which calls another script(some_script). some_script expects some input from the user. I have used printf statement for this purpose. But the problem is the variable value is not being accepted by the target script. I think this is because '\\' is being taken as an escape character in the script
The statement somewhat looks like this
printf 'yes\n$var1\n$var2\n$var3' | some_script
If i directly replace the variable with values it runs perfectly but i want the script to take the values from the variables. How do i achieve this?
There is a difference between "
and '
. Try
printf "yes\n$var1\n$var2\n$var3" | some_script
because with '
the variables won't get substituted.
Yes, \\
is a character that has to be escaped.
Use \\\\n
.
For more details we would need more details on how your script works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.