Artificial intelligent assistant

Is there a way to printf $@ verbatim? I want to write a script that echoes to `stdout` its `$@` verbatim, including any potential double-quotes, without a newline. What I have tried: > cat ./script1 #! /usr/bin/bash printf "%s %s" $0 $@ echo -n $0 $@ echo -n "$0 $@" > > ./script1 a "bc d" ./script1 abc d./script1 a bc d./script1 a bc d> I would like my script to run as follows: > ./script1 a "bc d" ./script1 a "bc d"> Is there a way to do this?

Your positional parameters do not contain any double quotes in your example:


./script1 a "bc d"


The double quotes there are simply to tell the shell that no word splitting should be performed on the space between `bc` and `d`.

If you want your second parameter to contain literal quotes you need to escape them to tell the shell they are literals:


./script1 a '"bc d"'


or


./script1 a \"bc\ d\"


You can use `printf` to print them in a format that can reused as shell input (escaped):


$ set -- a "bc d"
$ printf '%q\
' "$@"
a
bc\ d


As you can see this only escapes the space though.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy f3df0d48f9a1e073d7ecca9e37046620