Bash Scripting Language

1 answer below »
Bash Scripting Language
Answered Same DayOct 17, 2021

Answer To: Bash Scripting Language

Piyush answered on Oct 21 2021
149 Votes
NASA.sh
#!/bin/bash
DIRECTORY=$PWD
PICTURES_DIR=$DIRECTORY
DESCRIPTION_DIR=$DIRECTORY
# **********************
**********
# *** FUNCTIONS
# ********************************
function get_description {
sed -n '/ Explanation: <\/b>/,/

/p' $DIRECTORY/apod.html |
sed -e :a -e 's/<[^>]*>//g;/ grep -Ev 'Explanation:' |
tr '\n' ' ' |
sed 's/ /\n\n/g' |
awk 'NF { print $0 "\n" }' |
sed 's/^[ \t]*//' |
sed 's/[ \t]*$//' > $DESCRIPTION_DIR/description.txt
    DESCRIPTION=`/bin/cat description.txt`
    echo "DESCRIPTION:"
    echo $DESCRIPTION
}
function get_title {
    sed -n '/
/{N;/<\/b>
/p}' $DIRECTORY/apod.html |
    sed -e :a -e 's/<[^>]*>//g;/    tr '\n' ' ' |
    sed 's/^[ \t]*//' |
    sed -e 's/ *$//' > title.txt
    TITLE=`/bin/cat title.txt`
    echo "TITLE: "$TITLE
}
function get_credit {
    sed -n '/ Image Credit: <\/b>/,/<\/center>

/p' $DIRECTORY/apod.html |
    sed -e :a -e 's/<[^>]*>//g;/    tr '\n' ' ' |
    awk -F":" '{print $NF}' |
    sed 's/^[ \t]*//' |
    sed -e 's/ *$//' > Credit.txt
    CREDIT=`/bin/cat...

SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here