How to disable file name expansion in bash

To disable globbing in bash, use set -f. To enable it set +f.

Globbing is enabled by default

$ ls file*
file1  file2  file3  file4  file5
$ ls file?
file1  file2  file3  file4  file5

Turn off globbing

$ set -f
$ ls file*
ls: cannot access file*: No such file or directory
$ ls file?
ls: cannot access file?: No such file or directory

Turn on globbing

$ set +f
$ ls file*
file1  file2  file3  file4  file5
$ ls file?
file1  file2  file3  file4  file5

-f
Disable filename expansion (globbing).

via The Set Builtin, Bash Refernce Manual

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s