regex - Replace text in multiple file extentions -



regex - Replace text in multiple file extentions -

i'm trying replace text in several files using sed.

for example: replacing lion hawk in txt , md files within directory , subdirectories.

so far have research best (non-working) effort have is:

find . -type *.txt | xargs sed -i '' 's/lion/hawk/'

also trying add together md txt regex - *\.(txt|md) gives error.

thanks in advance help.

you want

find . -type f \( -name '*.txt' -o -name '*.md' \) -exec sed -i 's/lion/hawk/g' {} \;

the -o logical or on 2 -name predicates. can straight utilize -exec instead of piping xargs (both work).

edit updated quoting & parens.

regex sed

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -