Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #261830

Re: Sunrise and Sunset from terminal

From piorunz <piorunz@gmx.com>
Newsgroups linux.debian.user
Subject Re: Sunrise and Sunset from terminal
Date 2023-09-24 00:40 +0200
Message-ID <Hhjs5-b2dz-3@gated-at.bofh.it> (permalink)
References <HhiPn-b1JP-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 23/09/2023 22:51, sl91@gmx.com wrote:
> Is there a way to get sunrise and sunset time from command interpreter?
> I want to use its output for a script!

Of course.

#!/bin/bash

SunTimes=$(curl --silent "https://www.timeanddate.com/sun/uk/london"
2>/dev/null)

SunriseTime=$(echo "$SunTimes" | grep -o 'Sunrise Today.*' | awk '{print
$3}' | sed 's/[^0-9]//g')
SunsetTime=$(echo "$SunTimes" | grep -o 'Sunset Today.*' | awk '{print
$3}' | sed 's/[^0-9]//g')

# Optional: Insert a colon between hours and minutes
SunriseTime="${SunriseTime:0:2}:${SunriseTime:2}"
SunsetTime="${SunsetTime:0:2}:${SunsetTime:2}"

echo "Sunrise Today:" $SunriseTime
echo "Sunset Today:" $SunsetTime

--
With kindest regards, Piotr.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org/
⠈⠳⣄⠀⠀⠀⠀

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Sunrise and Sunset from terminal "sl91@gmx.com" <sl91@gmx.com> - 2023-09-24 00:00 +0200
  Re: Sunrise and Sunset from terminal ghe2001 <ghe2001@protonmail.com> - 2023-09-24 00:00 +0200
  Re: Sunrise and Sunset from terminal piorunz <piorunz@gmx.com> - 2023-09-24 00:40 +0200
    Re: Sunrise and Sunset from terminal Felix Miata <mrmazda@earthlink.net> - 2023-09-24 00:50 +0200
      Re: Sunrise and Sunset from terminal piorunz <piorunz@gmx.com> - 2023-09-24 01:00 +0200
        Re: Sunrise and Sunset from terminal Felix Miata <mrmazda@earthlink.net> - 2023-09-24 01:30 +0200
          Re: Sunrise and Sunset from terminal piorunz <piorunz@gmx.com> - 2023-09-24 01:40 +0200
          Re: Sunrise and Sunset from terminal Charles Curley <charlescurley@charlescurley.com> - 2023-09-24 05:00 +0200
      Re: Sunrise and Sunset from terminal Greg Wooledge <greg@wooledge.org> - 2023-09-24 01:10 +0200
        Re: Sunrise and Sunset from terminal piorunz <piorunz@gmx.com> - 2023-09-24 01:50 +0200
        Re: Sunrise and Sunset from terminal Andy Smith <andy@strugglers.net> - 2023-09-24 02:40 +0200
          Re: Sunrise and Sunset from terminal piorunz <piorunz@gmx.com> - 2023-09-24 03:00 +0200
          Re: Sunrise and Sunset from terminal Greg Wooledge <greg@wooledge.org> - 2023-09-24 05:10 +0200
            Re: Sunrise and Sunset from terminal Stefano <sl91@gmx.com> - 2023-09-24 11:30 +0200
  Re: Sunrise and Sunset from terminal Nate Bargmann <n0nb@n0nb.us> - 2023-09-24 05:00 +0200
  Re: Sunrise and Sunset from terminal Tom Browder <tom.browder@gmail.com> - 2023-09-24 22:40 +0200
  Re: Sunrise and Sunset from terminal Carles Pina i Estany <carles@pina.cat> - 2023-09-27 12:20 +0200
    Re: Sunrise and Sunset from terminal Curt <curty@free.fr> - 2023-09-27 17:50 +0200
    Re: Sunrise and Sunset from terminal Sven Hoexter <sven@stormbind.net> - 2023-09-29 16:10 +0200
  Re: Sunrise and Sunset from terminal Bruno Kleinert <fuddl@debian.org> - 2023-09-29 18:50 +0200
    Re: Sunrise and Sunset from terminal Karl Vogel <vogelke@pobox.com> - 2023-09-29 23:40 +0200

csiph-web