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