* for this. Use
grep 'ki' trial_file.txt or
grep -F 'ki' trial_file.txt.
Unless you pass it the
grep will return lines that contain a match anywhere, even if the whole line isn't a match. So all you have to do is match part of the line. You don't have to do anything special to indicate there may be more characters.
In a regular expression,
* means "zero or more of the previous item." This is an entirely different from its meaning in shell pathname expansion (see also this article,
man 7 glob, and this section). So, for example:
a, followed by any number of
xes (even none), followed by
a followed by any number of characters where each is
z, followed by
a, followed zero or more occurrences of the string
xyz, followed by
In this case, it seems like you're just searching for text. You don't need to use any regular expression metacharacters like
\ that have special meanings. That's why I suggest passing the
-F flag, which makes
grep search for "fixed strings" rather than performing regular expression matching.
If, however, you only want to match starting at the beginning of the line, then you do want to use a regular expression metacharacter:
^, as mjb2kmn suggests. This anchors your match to the start of the line. In that case you would run
grep '^ki' trial_file.txt.
For more information on the options
grep supports, see
man grep and the GNU Grep manual.
Although in general I suggest enclosing regular expressions in
' quotes, in this case no quoting is necessary because the shell does not perform any expansions on
^ki before passing them to