Skip to content

Instantly share code, notes, and snippets.

@khacanh
Last active February 15, 2017 05:12
Show Gist options
  • Save khacanh/75ceb601ed13b8d03e8c5de9f083addc to your computer and use it in GitHub Desktop.
Save khacanh/75ceb601ed13b8d03e8c5de9f083addc to your computer and use it in GitHub Desktop.
Vim and cli stuff

[1] Search and replace in multiple files

:argadd **/*.rb
:arg # list out arguments
:argdo %s/\(pattern\)/\1_asdf/ge | update

[2] Find magic

find . -name '*.rb' -newer Gemfile -print
find . -name '*.rb' -mtime +7 -print
find . -name '*.rb' -mtime +7 -print | xargs grep 'Sidekiq'

[3] Find and replace multiple files

find . -name '*.js' -exec bash -c 'mv $0 ${0/.js/.ts}' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment