Будет ли `cat ~ / foo *> ~ / results / output.txt` сохранять порядок` ~ / foo * `?

bash имеет встроенная переменная таймера

start=$SECONDS
# do stuff
end=$SECONDS
duration=$(( end - start ))
echo "stuff took $duration seconds to complete"

2
09.10.2016, 23:56
2 ответа

cat будет следовать порядку аргументов, если вы развернете ~ / foo * (в некоторых оболочках двойной табуляции или echo ~ / foo * ) вы увидите порядок.

Подстановочный знак * имеет алфавитный порядок.

SO глобальный вопрос: https://superuser.com/questions/192280/does-bashs-match-files-in-alphanumeric-order

3
27.01.2020, 21:59

Из man bash :

After word splitting, unless the -f option has been set, bash scans
each word for the characters *, ?, and [.  If one of these characters
appears, then the word is regarded as a pattern, and replaced with an
*alphabetically* sorted list of filenames matching the pattern

Обратите внимание на в алфавитном порядке . В вашем случае это будет:

$ cat foo.0001.0010 foo.0011.0020 foo.0021.0030

Вы можете расширить * с помощью C - x * после ввода * и перед нажатием введите .

1
27.01.2020, 21:59

Теги

Похожие вопросы