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
    

    f2e6e3eb-ce0c-4311-b17e-41e56f5907d1-image.png


Log in to reply
 

© Lightnetics 2024