Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created February 16, 2018 10:46
Show Gist options
  • Save dariocravero/1a4fd84661014e654d6e2e4c8e94c46a to your computer and use it in GitHub Desktop.
Save dariocravero/1a4fd84661014e654d6e2e4c8e94c46a to your computer and use it in GitHub Desktop.

here are two commands I made a while back and some of you may find handy to find and replace stuff on the terminal:

Find JS files with stuff:

findjs stuff

Find .view files with border:

findview border

They also have a replace counter part in place by adding an r at the end of the commands:

findviewr border muahaha
findjsr stuff nope

Add this to your ~/.bash_profile:

function findjs {
  find . -name '*.js' -not -path '*/node_modules/*' -not -path './deploy/cdm/*' -not -path './public/*' -not -path './bundle/*' -not -path './brain/*' -not -path './*.tmp.*' -exec grep "$1" {} \; -print
}
function findjsr {
  find . -name '*.js' -not -path '*/node_modules/*' -not -path './deploy/cdm/*' -not -path './public/*' -not -path './bundle/*' -not -path './brain/*' -not -path './*.tmp.*' -exec sed -i "s/$1/$2/g" {} \; -print
}

function findview {
  find . -name '*.view' -not -path '*/node_modules/*' -not -path './deploy/cdm/*' -not -path './public/*' -not -path './bundle/*' -not -path './brain/*' -not -path './*.tmp.*' -exec grep "$1" {} \; -print
}

function findviewr {
  find . -name '*.view' -not -path '*/node_modules/*' -not -path './deploy/cdm/*' -not -path './public/*' -not -path './bundle/*' -not -path './brain/*' -not -path './*.tmp.*' -exec sed -i "s/$1/$2/g" {} \; -print
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment