0

I meet a strange phenomenom when using grep on Solaris 10:
I try to use grep to find creat related DTrace probes. When in a folder (/data1/nan), it works OK:

bash-3.2# pwd
/data1/nan
bash-3.2# dtrace -l | grep creat*
   27 hotspot586         libjvm.so __1cHThreadsJcreate_vm6FpnOJavaVMInitArgs_pb_i_ vm-init-begin
   28 hotspot586         libjvm.so __1cHThreadsJcreate_vm6FpnOJavaVMInitArgs_pb_i_ vm-init-end
  574        fbt              aggr                   aggr_ioc_create entry
  575        fbt              aggr                   aggr_ioc_create return

While in another folder(/data1/nan/DTraceToolkit-0.99/Proc/), the grep can't find anything:

bash-3.2# cd /data1/nan/DTraceToolkit-0.99/Proc/
bash-3.2# pwd
/data1/nan/DTraceToolkit-0.99/Proc
bash-3.2# dtrace -l | grep creat*
bash-3.2#

Could anyone give any clue about this issue, thanks very much in advance!

Nan Xiao
  • 1,407

1 Answers1

2

The * is interpreted by the shell before it reaches grep. Quote it:

 dtrace -l | grep 'creat*'
muru
  • 72,889
  • :Yes, it worked on both folders. Why the dtrace -l | grep creat* can work on a folder while not in the other? I still can't figure out it. – Nan Xiao Jan 06 '15 at 03:36
  • 1
    @NanXiao creat* is expanded by the shell (globbing) into the names of files and folders starting with creat. Test it out with echo creat*. – muru Jan 06 '15 at 03:38