• queerlilhayseed@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 hours ago

    It’s a command line tool, used to search and filter text. According to wikipedia it stands for “global regular expression print”, which I never knew til today. Essentially, you give it some input text and a regular expression, and grep outputs all the parts of the input that match the regular expression. For example, if I run the command cat server_logs.log | grep ERROR* on my server, grep will print out all the lines in server_logs.log that have the word “ERROR”, filtering out all the “WARN” and “INFO” logs.

    * The | character is called a pipe, and it’s used to pass the output of one command line utility to another. In this example, the command line tool cat prints out the entire text of the file server_logs.log, and that output is then passed as an input to the next utility, grep, who filters it and outputs the filtered result. Piping is unnecessary in this case; in fact I have heard it rather upsettingly referred to as cat abuse, but that’s how my fingers remember how to filter files so I thought I’d present it as I wrote it.