-1

I have name file

  • hua.txt
  • hai.txt

if

print ls *{hua,las}* > taka.txt 

in taka.txt return

ls hua.txt *las*

i want to *las* not there,

i just want in taka.txt

ls hua.txt

and filter *{hua,las}* must there... too

please help

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Dwiyi
  • 101
  • 1
    For `bash` and `zsh` there is `shopt -s nullglob`, but see [this answer](http://unix.stackexchange.com/a/204944) for an in-depth discussion. – Satō Katsura Oct 10 '16 at 04:54

1 Answers1

3

Many shells have different handles when a pathname expansion (glob) fails to match anything.

For example, in bash you have two shell options:

  • nullglob:

    If a glob pattern fails to match anything, it is treated literally by default in bash. You can disable this behavior to return an empty string by setting the nullglob option beforehand:

    shopt -s nullglob
    
  • failglob:

    This is more explicit, when a glob pattern fails to match anything bash shows a relevant error message:

    shopt -s failglob
    

Given your circumstances, you should go with nullglob if you are using bash, or look out for any similar option if you are using a different shell.

heemayl
  • 54,820
  • 8
  • 124
  • 141