Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityHow to connect Google Workspace to Outlook(20.09.2026 um 02:02 Uhr)
•
Sicherheitslücken (CVE)Your AI Agent Should Be a Guest, Not a Tenant(20.09.2026 um 03:38 Uhr)
••
Sichere ProgrammierungA terrible lead to an AI junior(20.09.2026 um 03:41 Uhr)
•
Sichere ProgrammierungWhat Is a Browser-Based Tool? Examples, Benefits, and How They Work(20.09.2026 um 03:51 Uhr)
••
Sichere ProgrammierungVibe Coded Website SEO: Why AI-Built Websites Often Struggle to Rank(20.09.2026 um 04:08 Uhr)
•
Sichere ProgrammierungHot-Swap a 3D Avatar Without Publishing the Broken Frame(20.09.2026 um 04:12 Uhr)
•••
Windows Tipps & SecurityHow to connect Google Workspace to Outlook(20.09.2026 um 02:02 Uhr)
•
Sicherheitslücken (CVE)Your AI Agent Should Be a Guest, Not a Tenant(20.09.2026 um 03:38 Uhr)
••
Sichere ProgrammierungA terrible lead to an AI junior(20.09.2026 um 03:41 Uhr)
•
Sichere ProgrammierungWhat Is a Browser-Based Tool? Examples, Benefits, and How They Work(20.09.2026 um 03:51 Uhr)
••
Sichere ProgrammierungVibe Coded Website SEO: Why AI-Built Websites Often Struggle to Rank(20.09.2026 um 04:08 Uhr)
•
Sichere ProgrammierungHot-Swap a 3D Avatar Without Publishing the Broken Frame(20.09.2026 um 04:12 Uhr)
•••
Intelligence View
⚡ tsecurity.de Intelligence

HPR4088: Today I Learnt more Bash tips

Today I Learnt more Bash tips

Sgoti talks about supplying options to bash scripts

  • Tags: Bash tips, TIL, getopts
#!/bin/bash
# License: GPL v3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

#Name: showtime.sh
#Purpose: Time to make a show.
#Version: beta 0.01
#Author: SGOTI (Some Guy On The Internet)
#Date: 2023-12-29

#variables:

bindir=/usr/bin/

cat=${bindir}cat
date=${bindir}date
echo=${bindir}echo
mkdir=${bindir}mkdir

dirshow0=${HOME}/Music/hpr/shows
dirshow1=${dirshow0}/$(${date} +%Y)
dirqueue=${dirshow1}/queue/$(${date} +%F)
dirreserve=${dirshow1}/reserve-queue/$(${date} +%F)

#start:

function help() {
${cat} << EOH
Usage: $0 [-s] [-r] [-q] [-h] name-of-show

    -s    (Regular queue)
    -r    (Reserve queue)
    -q    (quit)
    -h    (help)

Examples:
        $0 -s name-of-show
        $0 -r name-of-show
        $0 -q
        $0 -h

EOH
}

## Use `getopts` to read user option into script. ##
while getopts ":s:r:q:h" option; do
    case $option in
        s)
        show=$OPTARG

function mkq () {
    ${mkdir} -v -p ${dirqueue}/${show}/edit;
    ${mkdir} -v -p ${dirqueue}/${show}/prod;
    ${cat} > ${dirqueue}/${show}/edit/${show}.md << _EOD_
# ${show} #

## subtitle ##

- Tags:



This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/ "CC-BY-SA 4.0 International").

_EOD_

    builtin pushd -n ${dirqueue}/${show}/edit;
    builtin pushd -n ${dirqueue}/${show}/prod;
}

        if [ -d ${dirshow1} ]; then
            mkq
        else
            ${echo} "Good Heavens! It's a new year.";
            ${mkdir} -v -p ${dirshow1};

            mkq
        fi
        ;;

        r)
        reserve=$OPTARG
function mkr () {
    ${mkdir} -v -p ${dirreserve}/${reserve}/edit;
    ${mkdir} -v -p ${dirreserve}/${reserve}/prod;
    ${cat} > ${dirreserve}/${reserve}/edit/${reserve}.md << _EOD_
# ${reserve} #

## subtitle ##

- Tags:



This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/ "CC-BY-SA 4.0 International").

_EOD_

    builtin pushd -n ${dirreserve}/${reserve}/edit;
    builtin pushd -n ${dirreserve}/${reserve}/prod;
}

        if [ -d ${dirshow1} ]; then
            mkr
        else
            ${echo} "Good Heavens! It's a new year.";
            ${mkdir} -v -p ${dirshow1};

            mkr
        fi
        ;;

        q)
        ${echo} "Goodbye.";
        exit
        ;;

        h)
        help
        exit
        ;;

        *)
        if [ -z "${option}" ]; then
            help
            exit 1
        fi

        ${echo} "Good Heavens! Invalid input.";
        help
        exit
        ;;
    esac
done


exit;
#!/bin/bash
# License: GPL v3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

#Name: sc.sh
#Purpose:
#Version: beta 0.01
#Author: SGOTI (Some Guy On The Internet)
#Date: 2023-12-31

#variables:

bindir=/usr/bin/

cat=${bindir}cat
date=${bindir}date
echo=${bindir}echo
ls=${bindir}ls
screen=${bindir}screen

#start:

    ${echo} -e "nStep 0: $(${date} +%F), $(${date} +%T)";

function help() {
${cat} << EOH
Usage: $0 [-b] [-s] [-k] [-h] name-of-show

    -b [y|n] (Create or kill, base sockets.)
    -s       (Create new sockets.)
    -k       (Kill sockets.)
    -h       (help menu)

Examples:
        $0 -b y
        $0 -b n
        $0 -s name-of-socket
        $0 -k name-of-socket
        $0 -h

EOH
}

    ${echo} -e "nStep 1: $(${date} +%F), $(${date} +%T)";

while getopts ":b:s:k:h:" option; do
    case "${option}" in
        b)
        userinput0=$OPTARG
        if [ ${userinput0} == "y" ]; then
        ${screen} -dmS apps;
        ${screen} -dmS jobby;
        ${screen} -ls;
        elif [ ${userinput0} == "n" ]; then
        # You don't need the entire name to kill the socket.
        ${screen} -X -S "app" kill
        ${screen} -X -S "job" kill
        ${screen} -ls;
        else
        ${echo} "Good Heavens!"
        ${screen} -ls;
            help
            exit 1
        fi
        ;;

        s)
        userinput0=$OPTARG
        ${screen} -dmS "${userinput0}";
            clear
        ${screen} -ls;
            ${echo} -e "nNew sockets: $(${date} +%F), $(${date} +%T)";
        ;;

        k)
        userinput0=$OPTARG
        ${screen} -XS ${userinput0} kill
            clear
        ${screen} -ls;
            ${echo} -e "nKill sockets: $(${date} +%F), $(${date} +%T)";
        ;;

        h)
        help
            ${echo} -e "nHelp menu: $(${date} +%F), $(${date} +%T)";
        exit
        ;;

        *)
        if [ -z "${option}" ]; then
            help
            exit 1
        fi

        ${echo} "Good Heavens! Invalid input.";
        help
        exit
        ;;
    esac
done

    ${echo} -e "nStep 2: $(${date} +%F), $(${date} +%T)";

exit;

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten HPR4088: Today I Learnt more Bash tips

Thematisch verwandte Begriffe: HPR4088, Today, Learnt, more · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93987 | rclone versions 1.56.0 through 1.75.0 contain a path traversal vulnerabi…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger • Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick