>>>>> Ed Morton <
morto...@gmail.com> writes:
>>>>> On 4/21/2017 1:19 PM, James wrote:
>> Why do I get this error and how to fix it?
>> $ printf "#!/bin/bash\n\n" > script.sh
>> bash: !/bin/bash\n\n": event not found
... And unless there's intent to actually use it, I'd suggest
disabling it altogether with 'set +H' (likely in ~/.bashrc.)
(FWIW, I use Readline's C-r function to search my history.)
> Remember the shell quoting rule is to use single quotes unless you
> NEED double quotes and then use double quotes unless you NEED no
> quotes. You don't need double quotes here so you shouldn't be using
> them and then your problems go away:
> $ printf "#!/bin/bash\n\n"
> -bash: !/bin/bash\n\n: event not found
> $ printf '#!/bin/bash\n\n'
> #!/bin/bash
I do not know the exact rules in play here, but I'm pretty sure
that some of my command lines featuring sed -e '/.../!d' got
that 'd' replaced with a prior 'df' command more than once --
despite of the use of single quotes. Hence I disabled it
altogether.
Never seen this issue occuring with a single \ escape (\!),
though.
--
FSF associate member #7257 ... And shopt -u hostcomplete also. B6A0 230E 334A