Linux731 shell工具;[]字符
问题
方括号 [] 匹配的是 字符集(Character Set)
为什么执行file[2-14].jpg,结果没有file2.jpg 只有file4.jpg
第一个命令:ls -l file[1-13].jpg -> 输出file1.jpg和file3.jpg
第二个命令:ls -l file[2-14].jpg -> 输出file4.jpg
第三个命令:ls -l file[3-10].jpg -> 报错
第四个命令:ls -l file[1-10].jpg -> 输出file1.jpg
第五个命令:ls -l file[0-9].jpg -> 输出file1.jpg到file9.jpg,包括file2.jpg
记录
root@192.168.235.20's password:┌────────────────────────────────────────────────────────────────────┐│ • MobaXterm 20.0 • ││ (SSH client, X-server and networking tools) ││ ││ ➤ SSH session to root@192.168.235.20 ││ • SSH compression : ✘ ││ • SSH-browser : ✔ ││ • X11-forwarding : ✔ (remote display is forwarded through SSH) ││ • DISPLAY : ✔ (automatically set on remote server) ││ ││ ➤ For more info, ctrl+click on help or visit our website │└────────────────────────────────────────────────────────────────────┘Last login: Wed Jul 30 19:18:10 2025 from 192.168.235.1
[root@web ~]# cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh
[root@web ~]#