Find and replace in file and overwrite file doesn't work, it empties the file

后端 未结 13 2119
深忆病人
深忆病人 2020-11-22 08:45

I would like to run a find and replace on an HTML file through the command line.

My command looks something like this:

sed -e s/STRING_TO_REPLACE/STR         


        
13条回答
  •  逝去的感伤
    2020-11-22 09:45

    To change multiple files (and saving a backup of each as *.bak):

    perl -p -i -e "s/\|/x/g" *  
    

    will take all files in directory and replace | with x this is called a “Perl pie” (easy as a pie)

提交回复
热议问题