hurnhu hurnhu - 1 month ago 4
Linux Question

how to use grep to search for a word beginning with...

okay im what im trying to do is use grep to look through a file, and find words starting with the lowercase letter s. for the life of my i cant get it. example of stuff in file.

sjpope pts/2 10:21am 43.00s 0.13s 0.01s man bc
rmschalk pts/3 10:22am 1.00s 0.10s 0.02s vi testb
jntrudel pts/4 10:23am 2.00s 0.09s 0.00s vi testb
tjbanks pts/5 10:41am 8.00s 0.06s 0.04s -ksh

and i want the output to only show the one starting with the s

kai kai

Have you tried using a regular expression? The ^ character will search from the beginning of the string. In your particular case, for example, if you want all results that start with a lowercase 's':

    cat file | grep ^s

or simply

grep ^s file