How to turn this command into a zsh function -


This command is what I want to translate into a zsh function, which performs a global search and changes to a string: Find

  ./type f -exec sed -i 's / string1 / string2 /' {} \;   

I tried:

  gr () {search / -type f -exec sed -i 's / $ 1 / $ 2 /' {} \; }   

But this does not seem to work.

The obvious error is the wrong quote - as always ' Expand in detail, use " instead of what you want - and you also want to global flag to sed: < Pre> gr () {find ./type f -exec sed -i "s / $ 1 / $ 2 / g" {} \ |}

However, this Not very zsh - Stylish ... the following is better for reading small and IMHO:

  gr () {sed -i "/ $ 1 / $ 2 / g "** / * (.)}   
  • ** Searches from R, but does not follow the simulation (use *** if you want to)
  • (.) Restricted to plain files

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -