Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top