Previous post:

Next post:

Hack 6. Use “shopt -s cdspell” to automatically correct mistyped directory names on cd

by Ramesh

Use shopt -s cdspell to correct the typos in the cd command automatically as shown below. If you are not good at typing and make lot of mistakes, this will be very helpful.

# cd /etc/mall
-bash: cd: /etc/mall: No such file or directory

# shopt -s cdspell

# cd /etc/mall

# pwd
/etc/mail

[Note: By mistake, when I typed mall instead of mail,
          cd corrected it automatically]
Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Previous post:

Next post:

{ 1 comment… read it below or add one }

1 Sathish January 26, 2011 at 12:33 am

very useful.
But I think the scope of “shopt -s cdspell” command is in the current terminal only.
How can i set it permanently so that whenever i login it will correct my typo error.

Thanks,
Sathish.

Leave a Comment

Previous post:

Next post: