문제

I am creating a build script to sweep through .html files after they are generated, I cannot seem to find out how to get this to work. Here is a snippet:

for PAGE in ${PAGES[@]}
do
    echo "\t\t\t- $DIR_PRE$PAGE.html"
    echo "\t\t\t- cleaning links in $DIR_PRE$PAGE.html"
    php helper.php output lang=$GET+environment=prod+page=$PAGE > $SITE/$DIR_PRE$PAGE.html
    find * -name \*.html -print0 | xargs -0 sed --in-place -e 's~.php~.html~g'
done

the last find command is supposed to find links with the .php extension with in the .html file and replace it with .html but I get this error:

sed: illegal option -- - usage: sed script [-Ealn] [-i extension] [file ...] sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...] - wiiu.html

도움이 되었습니까?

해결책

If you want to rename all .html files to .php in current directory recursively:

find . -name "*.html" -exec rename .html .php {} \;

Edit: misunderstood the question. You can use sed to replace strings within files:

sed -i 's/.html/.php/g' *.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top