How to change all occurrences of a word in all files in a directory

后端 未结 4 1822
感动是毒
感动是毒 2020-12-13 02:52

I was in the process of creating a User class where one of the methods was get_privileges();.

After hours of slamming my head into the keyb

4条回答
  •  离开以前
    2020-12-13 03:00

    A variation that takes into account subdirectories (untested):

    find /var/www -type f -exec sed -i 's/privelages/privileges/g' {} \;
    

    This will find all files (not directories, specified by -type f) under /var/www, and perform a sed command to replace "privelages" with "privileges" on each file it finds.

提交回复
热议问题