From cb5e8a876149f4d6d2c3a57bdd79a5cec2ce8a01 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Sun, 26 Mar 2023 01:22:34 -0400 Subject: [PATCH] cross platform sed --- loop_docs-19.sh | 36 ++++++++++++++++++++---------------- loop_docs.sh | 40 ++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/loop_docs-19.sh b/loop_docs-19.sh index 197e48fb..7a75a53e 100644 --- a/loop_docs-19.sh +++ b/loop_docs-19.sh @@ -2,32 +2,36 @@ set -xe -sed -i 's//dev/null | grep -q GNU; then + SED_INPLACE="sed -i" +else + SED_INPLACE="sed -i ''" +fi -sed -i 's/"version":.*/"version":"1.19.0"/' static/19-swagger.json +$SED_INPLACE 's/}}//' $file - sed -i 's/{{< version >}}/1.18.5/g' $file - sed -i 's/{{< relref "doc/\/docs/g' $file - sed -i 's/" >}}//g' $file - sed -i 's/\*\*Table of Contents\*\*//' $file - sed -i 's/weight:/sidebar_position:/g' $file + $SED_INPLACE 's/{{< toc >}}//' $file + $SED_INPLACE 's/{{< version >}}/1.18.5/g' $file + $SED_INPLACE 's/{{< relref "doc/\/docs/g' $file + $SED_INPLACE 's/" >}}//g' $file + $SED_INPLACE 's/\*\*Table of Contents\*\*//' $file + $SED_INPLACE 's/weight:/sidebar_position:/g' $file #sed -i 's/^slug:.*//' $file done -sed -i 's//dev/null | grep -q GNU; then + SED_INPLACE="sed -i" +else + SED_INPLACE="sed -i ''" +fi -sed -i 's/"version":.*/"version":"1.20-dev"/' static/latest-swagger.json +$SED_INPLACE 's/}}//' $file - sed -i 's/{{< version >}}/1.18.5/g' $file - sed -i 's/{{< relref "doc/\/docs/g' $file - sed -i 's/" >}}//g' $file - sed -i 's/\*\*Table of Contents\*\*//' $file - sed -i 's/weight:/sidebar_position:/g' $file + $SED_INPLACE 's/{{< toc >}}//' $file + $SED_INPLACE 's/{{< version >}}/1.18.5/g' $file + $SED_INPLACE 's/{{< relref "doc/\/docs/g' $file + $SED_INPLACE 's/" >}}//g' $file + $SED_INPLACE 's/\*\*Table of Contents\*\*//' $file + $SED_INPLACE 's/weight:/sidebar_position:/g' $file #sed -i 's/^slug:.*//' $file done for file in `find ./docs/usage/ -name "*.md"`; do - # note only works on linux, forget about it when attempting to run on macos # hide hugo toc - sed -i 's/title:.*//' $file + $SED_INPLACE 's/title:.*//' $file done for file in docs/*; do