-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

Dwiyi
  • 101

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
  • 56,300