Home > Mobile >  Clearing a character string variable set in BASH
Clearing a character string variable set in BASH

Time:11-10

In learning to use BASH, I somehow set !" such that it is interpreted as a character string in each instance BASH interprets !" . For example:

2013-MP-MFY3Y:~ williamdwyer$ echo !"

echo "FRom faireſt creatures we deſire increaſe,"

FRom faireſt creatures we deſire increaſe,

2013-MP-MFY3Y:~ williamdwyer$ rm !"

rm "FRom faireſt creatures we deſire increaſe,"

Problems arise in that every string ending in !" now substitutes in "FRom faireſt creatures we deſire increaſe," -- another example:

2013-MP-MFY3Y:~ williamdwyer$ echo "Now!"

echo "Now"FRom faireſt creatures we deſire increaſe,"

How may I clear this mapping out?

Thank you!

I've tried rm, unset, echo "" > "!"", echo "" > '!"' . I obviously do not understand how !" is being interpreted.

CodePudding user response:

This is bash's Using History Interactively. The ! character starts a History Expansion

!" is recalling the last command you entered that starts with "

A demo:

$ "foo bar"
bash: foo bar: command not found

$ echo !"
echo "foo bar"
foo bar
  • Related