Using cd command to navigate directories in Ubuntu which have special characters [duplicate]
Solution 1:
That error is happening because the !
(bang) is a shortcut that allows you re-run a command from your history. Ex: This command re-runs command #1504 from my history.
$ !1504
To avoid that issue, try encapsulating your directory name with single quotes.
$ cd '!)e$!gn&(reate'
That being said, while Ubuntu (Linux) will let you name directories in this way, I would highly recommend against it. Using special characters in directory names can make them difficult to read, and if you are using a reserved character you will always need to escape it or encapsulate the directory name in quotes.
Solution 2:
You use \
before special characters
cd \!\)e\$\!gn\&\(reate
You can also put entire foldername in single quotes
cd '!)e$!gn&(reate'
You can encapsulate entire path within single quotes
cd 'Desktop/!)e$!gn&(reate'
if you want to refer a path inside /home/username directory: just add ~/
before path in single quotes
cd ~/'Desktop/!)e$!gn&(reate'