Search code examples
regexgrepposix

To search for .zip files inside of a download.log,


I am struggling with an assignment.

This is the assignment: Collect specific entries from file or pipe by regular expression or simple text search - from download.log, get all zip file names and their size. Put the output into a new file.

I tried to tackle this problem with grep.

This is what I got so far: grep -E -w '......*|.zip' download.log Executing this command just gives me the entire download.log

Does anyone have ideas how to tackle this problem? Thanks in advance


Solution

  • This command should work for you: grep -E '\S*.zip' download.log

    \S means that we search for non-whitespace character. Meaning alphanumeric characters, hyphen, dot or underline followed by .zip

    If you want grep to only output the matches simply use the -o option additionally.