How do I match a string ending 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 ends with fit, in this case it is the word fit.

    $ grep "fit\>" textfile
    If the boots fit
    

    21275700-b717-4943-b505-351c9b59717f-image.png


Log in to reply
 

© Lightnetics 2024