I recently encountered a situation where I tried to use !
as a record separator for my string array in shell script. When I used it in my shell script, the script got expanded automatically. An example to reproduce the situation can be as below.
check_variable="Hello"
echo "$check_variable"
Output: Hello
###For multiple strings, I tried to concatenate with ! as a record separator.
echo "$check_variable !"
Output: echo "$check " > Results.txt
Then after some research, I had figured out !
is in fact a special character and should not be used as record separators. So, exactly why is !
used? Is there any way I can turn off the !
character and use it in my shell script?