Use gnu sed if possible
This commit is contained in:
parent
799ba547ff
commit
391d137a21
|
@ -145,6 +145,10 @@ if [[ $# -ne 0 ]]; then
|
|||
fi
|
||||
|
||||
|
||||
SED=$(which gsed 2>/dev/null)
|
||||
[[ $? -ne 0 ]] && SED=$(which sed 2>/dev/null)
|
||||
[[ -z $SED ]] && fatal "can't find sed in path"
|
||||
|
||||
# Read config file
|
||||
if [[ ! -e ${CONFIG} || ! -f ${CONFIG} ]]; then
|
||||
fatal "config file '$CONFIG' doesn't exist or isn't a plaintext file"
|
||||
|
@ -193,10 +197,11 @@ elif [[ $MODE == "test" ]]; then
|
|||
url="${site_url[$idx]}"
|
||||
|
||||
temp=$(newtempfile)
|
||||
curl -sL "$url" | sed 's/>/>\n/g;s/</\n</g;' | awk NF | egrep -v "^<.*>$" > ${temp}
|
||||
|
||||
curl -sL "$url" | ${SED} 's/>/>\n/g;s/</\n</g;' | awk NF | egrep -v "^<.*>$" > ${temp}
|
||||
if [[ $TEST_USERES -eq 1 ]]; then
|
||||
sedcmd="/${site_re_start[$idx]}/,/${site_re_end[$idx]}/p"
|
||||
cat "$temp" | sed -n "$sedcmd"
|
||||
cat "$temp" | ${SED} -n "$sedcmd"
|
||||
else
|
||||
cat "$temp"
|
||||
fi
|
||||
|
@ -251,11 +256,11 @@ for x in ${!site_name[@]}; do
|
|||
outfile="${OUTDIR}/${thisfile}"
|
||||
temp=$(newtempfile)
|
||||
temp2=$(newtempfile)
|
||||
curl -sL "$url" | sed 's/>/>\n/g;s/</\n</g;' | awk NF | egrep -v "^<.*>$" > "${temp}"
|
||||
curl -sL "$url" | ${SED} 's/>/>\n/g;s/</\n</g;' | awk NF | egrep -v "^<.*>$" > "${temp}"
|
||||
sedcmd="/${re_start}/,/${re_end}/p"
|
||||
|
||||
echo -e "SITE: ${sitename}\nURL: $url\n\n" >${temp2}
|
||||
cat "$temp" | sed -n "$sedcmd" >> ${temp2}
|
||||
cat "$temp" | ${SED} -n "$sedcmd" >> ${temp2}
|
||||
|
||||
if [[ -e ${outfile} ]]; then
|
||||
# has it changed?
|
||||
|
|
Loading…
Reference in New Issue