Snippets Collections
this command puts a symlink of .env in every docker-compose folder
it creates an extra .env with a ~ like .env~ if the file already exists. Just ignore it. I could create a line of code that removes it

find /mnt/docker/docker-compose-files/ -mindepth 1 -maxdepth 1 -type d -exec ln -sbf /mnt/docker/docker-compose-config/.env {}/.env \;

remove every .env~ file in every docker-compose folder

find /mnt/docker/docker-compose-files/ -mindepth 1 -maxdepth 1 -type d -exec rm {}/.env~ \;

create a symbolic link in one specified directory

ln -sbf /mnt/docker/docker-compose-config/.env /mnt/docker/docker-compose-files/mongodb/.env

find the .env file in specified directory

find /mnt/docker/docker-compose-files -name .env
#!/bin/bash
MYIP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
for i in $(docker ps --format '{{.Names}}'); do
    docker port $i | grep -oP '(?<=0:)[1-9].*' | while read -r MYPORT; do
        if [[ -n $MYPORT ]]; then
            MYRESPONSE=$(curl -Is --max-time 0.5 $MYIP:$MYPORT | head -1 | grep -oP '[0-9][0-9][0-9]')
            pat="2|3"
            if [[ ${MYRESPONSE:0:1} =~ $pat ]]; then
                printf "| %20s | %-20s | %-10s | \n" "$i" "$MYIP:$MYPORT" "$MYRESPONSE"
            fi
        fi
    done
done
#!/bin/bash
#####################################################################
#Author:Irfan Khan
#Description:this function will used to donwload & move that file to
#desired location
#####################################################################
download(){
    #$url=$1
    wget -cO - https://gist.github.com/chales/11359952/archive/25f48802442b7986070036d214a2a37b8486282d.zip > dbtest.zip
    if [[ -f dbtest.zip ]];
    then
        mv dbtest.zip ./mydb_data
        exit 0
    else
        echo "hey file not moved some thing went wrong.."
    fi
}

download  #calling the function
#To Download File From Remote Server To Local Machine Using SCP.using Powershell or gitbash 
scp -i .\keys.pem ubuntu@XX.XX.XX.XX:/home/ubuntu/Dir/fileName  C:\Users\USER\Downloads\
#!/bin/bash
# Bash Menu Script Example

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
            echo "you chose choice 1"
            ;;
        "Option 2")
            echo "you chose choice 2"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Quit")
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done
star

Sat Apr 02 2022 08:51:08 GMT+0000 (UTC)

#shellscript
star

Mon Oct 18 2021 07:57:50 GMT+0000 (UTC) https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script

#bash #sh #script #shell #shellscript

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension