Skip to content

Instantly share code, notes, and snippets.

@charrismatic
Last active August 10, 2019 20:47
Show Gist options
  • Save charrismatic/0912deb45b0c6a0fe2adec549e4fddf7 to your computer and use it in GitHub Desktop.
Save charrismatic/0912deb45b0c6a0fe2adec549e4fddf7 to your computer and use it in GitHub Desktop.
Linux commands explained

find, filter, execute... , grep, replace

find ./data -type f -name "*.csv" -exe cat {} \; | grep "andres" | sed '/  //g'

the same thing broken down by each action

find ./data \               # <- find everything recursively in the path './data' 
    -type f \               # <- that are type 'file'
    -name "*.csv" \         # <- the name of the file ends with '.csv'
    -exe cat {} \; \        # <- every time you find one read it and put it on the screen
        | grep "andres" \   # <- instead of the screen send it to the grep program and match lines that say "andres
        | sed '/  //g'      # <- take the matched lines and send them to sed, replace all double 'spaces' with nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment