Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Bash Assignment

1 answer below »
Answered Same Day Oct 26, 2021

Solution

Aditya answered on Oct 28 2021
141 Votes
function gettitleanddescription {

if [ ! -e /tmp/apod.html ]; then
findurlbydate
fi
    IMGDET="`grep -o '
.*
' /tmp/apod.html | sed 's/\(
\|<\
\)
g' | sed -n '2p'`"
        echo "TITLE: `grep -o '
.*
' /tmp/apod.html | sed 's/\(
\|<\
\)
g' | sed -n '1p'`"
        echo " "
        echo "EXPLANATION:"
        echo " "
sed -n '
Explanation: <\
,
p> p' /tmp/apod.html |
sed -e :a -e 's
[^>]*
g;
N;
a' |
grep -Ev 'Explanation:' |
tr '\n' ' ' |
sed 's/ /\n\n/g' |
awk 'NF { print $0 "\n" }' |
sed 's/^[ \t]*
' |
sed 's/[ \t]*$
'         
        
    
        
    
        IMG="$(echo -e "${IMGDET}" | sed -e 's/^[[:space:]]*
' -e 's/[[:space:]]*$
')"
        
    
sed -n "
$IMG <\
,
\/cente
p" /tmp/apod.html |
sed -e :a -e 's
[^>]*
g;
N;
a' |
grep -Ev '$IMG' |
tr '\n' ' ' |
sed 's/ /\n\n/g' |
awk 'NF { print $0 "\n" }' |
sed 's/^[ \t]*
' |
sed 's/[ \t]*$
'
        

}
function findurlbydate {

    dt="$1"
    URL="http:
apod.nasa.gov/apod/ap${dt}.html"
    
wget "${URL}" --quiet -O /tmp/apod.html
grep -m 1 jpg /tmp/apod.html | sed -e 's
' -e 's
' -e 's/.*=
' -e 's/"
g' -e 's/^/http:\/\/apod.nasa.gov\/apod\
' > /tmp/pic_url
}
#Main...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here