shell - the meta character in linux soft quoting -
[root@z ~]# echo \n n [root@z ~]# echo "\n" \n [root@z ~]# echo '\n' \n
and
[root@z ~]# echo '\\' \\ [root@z ~]# echo "\\" \ [root@z ~]# echo \\ \
what's problem?
soft quoting can disable \ or not???
in order interpret escape sequences many echo
versions must invoked argument -e described posix specifications under "on xsi-conformant systems.. " in page echo
. circumvent potential inconsistency instead use more portable printf
utility. here examples:
output actual newline character:
printf "\n"
output uninterpreted "\n" character string:
printf "\\\n"
if absolutely want use echo
still, can pass -e
option follows:
output actual newline character:
echo -ne "\n"
output uninterpreted "\n" character string:
echo -n "\n"
single ticks verse quotes have no bearing on operation of escape sequences. differentiation of single ticks verse quotes useful in regards glob , variable expansion. , find on shells, namely ash variants (dash) -e option not supported, , instead shell behaves if -e default. again, circumvent potentially confusing , non-portable scenario use printf
.
Comments
Post a Comment