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=Helloecho $check_variableOutput: Hello###For multiple strings, I tried to concatenate with ! as a record separator. echo $check_variable !Output: echo $check  > Results.txtThen 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?
why is ! character used in shell scripts
shell;shell script
Actually, there is a wonderful explanation on why ! is used from here. To understand the command more clearly, I did the following commands. pwd- It gives the present working directory.!pwd - It executes the previously executed pwd command.This setting could be dangerous as there are chances that an user might execute !rm by mistake and thus resulting in unprecedented results.  Another method to test the effectiveness of the ! character would be,echo 12345647 >> ramesh.txtcat ramesh.txt12345647!echocat ramesh.txt1234564712345647As we can see the !echo command had in fact got executed and appended the line 1234567 to the file. Though it is not advised to use the special characters as file separators or record separators in the script, this setting could be overrided by executing the below command. set -H turns it on; set +H turns it off.