How do I match a string beginning with certain characters using grep?
-
Note: Be careful with the I/O redirection characters
<
and>
always ensure important files can be easily retrieved from backups.Example textfile used.
$ cat textfile If the boots fits boots bootss bloom beautiful
We want to match the strings matching
boots
at the beginning of a string, in this case it is the word boots.$ grep "\<boots" textfile If the boots fit bootsy was here bootss
© Lightnetics 2024