fishとbashのワイルドカードは違う

やはりbashとは色々と違うようだ

bashの場合

echo $SHELL
/bin/bash

bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)

ls test*.py
test1.py test2.py test3.py test4.py

ls test[1-4].py
test1.py test2.py test3.py test4.py

 

fishの場合

echo $SHELL
/usr/bin/fish

fish --version
fish, version 2.7.1

ls test*.py
test1.py  test2.py  test3.py  test4.py

ls test[1-4].py
ls: cannot access 'test[1-4].py': No such file or directory

 

Wildcards

If a star (*) or a question mark (?) is present in the parameter, fish attempts to match the given parameter to any files in such a way that:

  • ? can match any single character except ‘/’.
  • * can match any string of characters not containing ‘/’. This includes matching an empty string.
  • ** matches any string of characters. This includes matching an empty string. The matched string may include the / character; that is, it recurses into subdirectories. Note that augmenting this wildcard with other strings will not match files in the current working directory ($PWD) if you separate the strings with a slash (“/”). This is unlike other shells such as zsh. For example, **\/*.fish in zsh will match .fish files in the PWD but in fish will only match such files in a subdirectory. In fish you should type ***.fish to match files in the PWD as well as subdirectories.

cf. Glob matching (wildcards) in fish shell not matching bash behavior
https://stackoverflow.com/questions/28838665/glob-matching-wildcards-in-fish-shell-not-matching-bash-behavior

cf. fish: Documentation
https://fishshell.com/docs/current/index.html

cf. Linux【ワイルドカードと正規表現】の違い, 展開の動作 ~ls, grep, findでの具体例の解説~
https://milestone-of-se.nesuke.com/sv-basic/linux-basic/wildcard-regular-expression

コメント

タイトルとURLをコピーしました