【環境配置】ubuntu中shell命令不能識別萬用字元的解決辦法之一

yingxian_Fei發表於2017-10-19

今天遇上一個憂桑的問題。配置完編譯環境,發現shell指令碼或者終端中無法識別萬用字元”*“,使用時提示如下錯誤資訊:

cannot access *: No such file or directory

如下為我使用的解決辦法 ,記錄下希望幫助到需要的人:

1、檢視nullglob配置

執行shopt命令,檢視nullglob選型的配置,命令如下:

shopt
shopt的使用說明可以查閱如下頁面的介紹:http://man.linuxde.net/shopt,如下為我不可用時的配置:

autocd          off
cdable_vars     off
cdspell         off
checkhash       off
checkjobs       off
checkwinsize    on
cmdhist         on
compat31        off
compat32        off
compat40        off
compat41        off
compat42        off
complete_fullquote      on
direxpand       off
dirspell        off
dotglob         off
execfail        off
expand_aliases  on
extdebug        off
extglob         on
extquote        on
failglob        off
force_fignore   on
globstar        off
globasciiranges off
gnu_errfmt      off
histappend      on
histreedit      off
histverify      off
hostcomplete    off
huponexit       off
interactive_comments    on
lastpipe        off
lithist         off
login_shell     on
mailwarn        off
no_empty_cmd_completion off
nocaseglob      off
nocasematch     off
nullglob        on
progcomp        on
promptvars      on
restricted_shell        off
shift_verbose   off
sourcepath      on
xpg_echo        off

可以看到nullglob選型當前時off狀態。

2、啟用nullglob選型

使用如下命令啟用nullglob選型。

shopt -s nullglob
之後再去試試吧。

相關文章