macosshellunixgeektool

Removing text in unix shell


Sorry, I'm pretty new to coding. I'm just trying to remove the CST that follows the end of the string. The final output that I'm trying to get says "Sunset: 4:38 PM CST". Exclude the quotation marks.

Here is the code that I'm using within the shell.

curl http://m.wund.com/US/MN/Winona.html | grep 'Sunset' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed -e 's/Sunset/Sunset: /g' | sed -e 's/PST//g'

Solution

  • Just change:

    ... | sed -e 's/PST//g'
    

    to

    ... | sed -e 's/CST//g'
    

    You might also want to invoke curl -s instead of just curl to omit all the downloading stuff.