How do I use sed to make every letter in a file lowercase?



  • Link to GNU sed substitute documentation: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html

    In this example we will be using the following:
    \L - Turn the replacement to lowercase.

    The sample file we're working with is:

    this is my first ip 10.50.20.1
    grapes
    apples
    pears
    this is the first block
    oranges
    PLUMS
    
    this is my second ip 10.50.20.2
    this is my duplicate ip 10.50.20.2
    grapes
    apples
    pears
    this is the second block
    oranges
    PLUMS
    
    this is my third ip 10.50.20.3
    grapes
    apples
    pears
    this is the third block
    oranges
    plumsp
    

    This command will change the uppercase PLUMS to plums. This command send the output to the screen, redirect the output to another file to save it or use the -i option.

    $ cat grepfile | sed -e 's/\(.*\)/\L\1/'
    


© Lightnetics 2024