From 7122d616e20daccbc8dc9db20428f2bd54e9de46 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 01:13:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20READ.ME=20=D0=B4=D0=BB=D1=8F=20BASH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snipplets/code/Bash/README.md | 5 +++++ snipplets/code/Bash/command_exists.sh | 2 ++ snipplets/code/Bash/file_folder_exists.sh | 4 ++++ snipplets/code/Bash/irc_logger.sh | 3 +++ snipplets/code/Bash/unix-socket-server.sh | 2 ++ 5 files changed, 16 insertions(+) create mode 100644 snipplets/code/Bash/README.md diff --git a/snipplets/code/Bash/README.md b/snipplets/code/Bash/README.md new file mode 100644 index 0000000..889d37b --- /dev/null +++ b/snipplets/code/Bash/README.md @@ -0,0 +1,5 @@ +# Bash & Unix Shell + +* [UnixSocket сервер на `nc`](unix-socket-server.sh) +* [Проверка наличия команды](command_exists.s) +* [Проверка наличия файла/директории](file_folder_exists.sh) diff --git a/snipplets/code/Bash/command_exists.sh b/snipplets/code/Bash/command_exists.sh index 7a85ae7..5cb50b2 100644 --- a/snipplets/code/Bash/command_exists.sh +++ b/snipplets/code/Bash/command_exists.sh @@ -5,6 +5,8 @@ if ! [ -x "$(command -v git)" ]; then exit 1 fi +# OR + if ! command -v crystal &> /dev/null then echo " could not be found" diff --git a/snipplets/code/Bash/file_folder_exists.sh b/snipplets/code/Bash/file_folder_exists.sh index 47b823b..ec3e25a 100644 --- a/snipplets/code/Bash/file_folder_exists.sh +++ b/snipplets/code/Bash/file_folder_exists.sh @@ -9,6 +9,8 @@ else echo "$FILE does not exist." fi +# OR + [ -f /etc/resolv.conf ] && echo "/etc/resolv.conf exists." # Check directory exists @@ -18,4 +20,6 @@ if [ -d "$DIR" ]; then echo "$DIR is a directory." fi +# OR + [ -d /etc/docker ] && echo "/etc/docker is a directory." diff --git a/snipplets/code/Bash/irc_logger.sh b/snipplets/code/Bash/irc_logger.sh index b594e44..16002c1 100755 --- a/snipplets/code/Bash/irc_logger.sh +++ b/snipplets/code/Bash/irc_logger.sh @@ -1,5 +1,8 @@ #!/bin/bash +# TODO: Добавить описание +# TODO: Добавить в README.md + # https://linuxconcept.com/making-a-simple-irc-chat-bot-logger-using-bash-script/ nick="blb$$" diff --git a/snipplets/code/Bash/unix-socket-server.sh b/snipplets/code/Bash/unix-socket-server.sh index 4cc7e66..219bd4b 100755 --- a/snipplets/code/Bash/unix-socket-server.sh +++ b/snipplets/code/Bash/unix-socket-server.sh @@ -1,5 +1,7 @@ #!/bin/bash +# TODO: Добавить описание и пример работы + # TCP # coproc nc -l localhost 3000