遇到奇怪报错啊。
搞半天,原来是引号的问题啊。
如下, 可以看到 pgrep -a 'tc*' 加个引号就好了。单双引号都可以。 但是没有就不行。
为什么呢? 估计是被展开为 当前目录下的文件了吧。
OCBS[353]:/home/ocbs/ibsbase> pgrep -a hbo
2208631 hboxctl start_region OCBS
2208634 hboxam OCBS 32786
2208635 hboxqm OCBS 32786
2208637 hboxas OCBS 32786 0
OCBS[353]:/home/ocbs/ibsbase> pgrep -a hbox*
2208631 hboxctl start_region OCBS
2208634 hboxam OCBS 32786
2208635 hboxqm OCBS 32786
2208637 hboxas OCBS 32786 0
OCBS[353]:/home/ocbs/ibsbase> pgrep -a tco*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase> pgrep -a tc*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase> pgrep -a tcp*
OCBS[353]:/home/ocbs/ibsbase> pgrep -a tcotc*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase> pgrep -a tcotcp*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase>
OCBS[353]:/home/ocbs/ibsbase> pgrep -a tco*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase> pgrep -a 'tco*'
79 watchdogd
508 card0-crtc0
509 card0-crtc1
510 card0-crtc2
511 card0-crtc3
512 card0-crtc4
513 card0-crtc5
514 card0-crtc6
515 card0-crtc7
861 /usr/sbin/sedispatch
895 /usr/libexec/switcheroo-control
1838 /usr/libexec/gsd-smartcard
2209303 tcotcp
2209398 tcotcp
OCBS[353]:/home/ocbs/ibsbase> pgrep -a hbox*
2208631 hboxctl start_region OCBS
2208634 hboxam OCBS 32786
2208635 hboxqm OCBS 32786
2208637 hboxas OCBS 32786 0
OCBS[353]:/home/ocbs/ibsbase> pgrep -a h*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase> pgrep -a hb*
pgrep: only one pattern can be provided
Try `pgrep --help' for more information.
OCBS[353]:/home/ocbs/ibsbase> ll hb*
-rwxr-xr-x 1 ocbs ocbs 17573 6月 8 2021 hbasefun.h
-rwxr-xr-x 1 ocbs ocbs 292 6月 8 2021 hbase.h
OCBS[353]:/home/ocbs/ibsbase> ll hbox*
ls: 无法访问 'hbox*': 没有那个文件或目录
OCBS[353]:/home/ocbs/ibsbase> ll tco*
-rwxr-xr-x 1 ocbs ocbs 30057 6月 23 2021 tcotcp.dbC
-rwxr-xr-x 1 ocbs ocbs 30103 6月 8 2021 tcotcp.dbC_bak
-rwxr-xr-x 1 ocbs ocbs 30057 6月 21 2021 tcotcp.dbC.jhq
OCBS[353]:/home/ocbs/ibsbase>
pgrep -a '*'
无效的前导常规表达式OCBS[353]: