Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash jump to

#!/bin/bash

read -p 'Input something > ' one_thing

while true; do
  read -p 'Input something else > ' another_thing

  # Write some code to check if the requirements are met
  # Let's say in this case they are when the variable `thing_to_work` equals `done`

  if [[ "${thing_to_work}" == 'abcde' ]]; then
    break # Exit the loop
  else
    echo 'The requirements were not met, so the loop will start again'
  fi
done
Comment

bash jump to

#!/bin/bash

# BAT / CMD goto function
function goto
{
    label=$1
    cmd=$(sed -n "/^:[[:blank:]][[:blank:]]*${label}/{:a;n;p;ba};" $0 | 
          grep -v ':$')
    eval "$cmd"
    exit
}

apt update

# Just for the heck of it: how to create a variable where to jump to:
start=${1:-"start"}
goto "$start"

: start
goto_msg="Starting..."
echo $goto_msg
# Just jump to the label:
goto "continue"

: skipped
goto_msg="This is skipped!"
echo $goto_msg

: continue
goto_msg="Ended..."
echo "$goto_msg"

# following doesn't jump to apt update whereas original does
goto update
Comment

PREVIOUS NEXT
Code Example
Shell :: vue google sign in github 
Shell :: ubuntu 20.04 dash is conflicting with dock 
Shell :: ubuntu erlang 23 
Shell :: bash if string does not start with 
Shell :: sharepoint list password column 
Shell :: how to close terminal 
Shell :: beanstalk no log in cloudwatch 
Shell :: wget quier 
Shell :: retour chariot avec echo bash 
Shell :: find jpg or png 
Shell :: how to deploy project on github 
Shell :: set nairobi timezone ubuntu server 18.04 
Shell :: Running setup.py install for pyahocorasick ... error 
Shell :: boot up batch script 
Shell :: sonarcube exclude rule via powershell 
Shell :: Terabyte 
Shell :: journalctl log reviews catalog boot sshd 
Shell :: mining from cli 
Shell :: which display manager is active/running 
Shell :: fix errors occurred when installing a file in linux 
Shell :: disable dashboardmac 
Shell :: kontiki cli 
Shell :: canvas api python pypi 
Shell :: how do confirm a commit revert git 
Shell :: pacman manager package invalid problem 
Shell :: powershell map array 
Shell :: install onedrive in ubuntu 18.04 
Shell :: shell script for aws lightsail launch 
Shell :: kubernetes get -o yaml 
Shell :: Cloning mercurial and setting it up in your machine 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =