You can't "skip" a running process with bash. According to this page from bash docs, even if it had a skip behavior for a signal, it would wait until the process finished execution to issue the skip, effectively skipping only the following instruction. You can, though, change the way your script runs so that it kills the unzip process for you, if running on background, upon receiving a SIGINT for example (guide).

Answer from Zip on Stack Exchange
Top answer
1 of 2
1

To implement those the two logics:

  1. If no arguments at all, run all functions
  2. For each argument passed, skip some function execution

You can do it like this:

#!/bin/bash

function func_i {
  echo "I am i."
}

function func_b {
  echo "I am b."
}

function main {

  # Check if there are no arguments, run all functions and exit.

  if [ $# -eq 0 ]; then
    func_i
    func_b
    exit 0
  fi

  # Parse arguments -i and -b, marking them for no execution if they are passed to the script.

  proc_i=true
  proc_b=true

  while getopts "ib" OPTION; do
      case $OPTION in
      i)
          proc_i=false
          ;;
      b)
          proc_b=false
          ;;
      *)
          echo "Incorrect options provided"
          exit 1
          ;;
      esac
  done

  # Execute whatever function is marked for run.

  if $proc_i; then func_i; fi
  if $proc_b; then func_b; fi
}

main "$@"

Some explanations:

$# returns the number of arguments passed to the script. If $# is equal to 0, then no arguments were passed to the script.

getops accepts switches -i and -b, all other switches will result in error handled in the *) case.

2 of 2
1

You could black list items from the list of functions that are called by default. Something like:

#!/bin/bash

list='a b c d e f g h i'

# define some functions
for name in $list; do
        eval "func_$name() { echo func_$name called with arg \$1; }"
done

# black list items from list
for x; do
        list=$(echo "$list" | tr -d ${x#-})
done

for name in $list; do
        func_$name $name
done

But frankly it makes more sense to do something like:

$ cat script.sh 
#!/bin/bash

list='a b c d e f g h i'
test $# = 0 && set -- $list # set default list of functions to call

# define some function
for name in $list; do
        eval "func_$name() { echo func_$name called with arg \$1; }"
done

for name; do
        func_$name $name
done
$ bash ./script.sh 
func_a called with arg a
func_b called with arg b
func_c called with arg c
func_d called with arg d
func_e called with arg e
func_f called with arg f
func_g called with arg g
func_h called with arg h
func_i called with arg i
$ bash ./script.sh c g
func_c called with arg c
func_g called with arg g
Discussions

To skip operations in UNIX shell
hi i am having a acript for which i need to skip the execution of some lines and to continue with remaining lines for eg script.sh rm text for i in * do . . . . . if [x = y] then rm i want to skip the execution of the lines and to start with if [x = y] then rm More on community.unix.com
🌐 community.unix.com
11
0
May 2, 2014
linux - Print a file, skipping the first X lines, in Bash - Stack Overflow
I have a very long file which I want to print, skipping the first 1,000,000 lines, for example. I looked into the cat man page, but I did not see any option to do this. I am looking for a command to do this or a simple Bash program. More on stackoverflow.com
🌐 stackoverflow.com
To skip operations in UNIX shell
hi i am having a acript for which i need to skip the execution of some lines and to continue with remaining lines for eg script.sh rm text for i in * do . . . . . if [x = y] then rm i want to skip the execution of the lines and to start with if [x = y] then rm More on unix.com
🌐 unix.com
11
0
October 19, 2017
go to / skip in script
Hi all I have some script like this #!/bin/bash mv /tmp/file1 tmp/file2 if $? -eq 0 ]] ; then cp /tmp/filetest/ tmp/file3 if $? -eq 0 ]] then echo "succes" else echo "failed" fi else … More on unix.com
🌐 unix.com
0
0
November 4, 2009
🌐
Unix Community
community.unix.com › shell programming and scripting
To skip operations in UNIX shell - Shell Programming and Scripting - Unix Linux Community
May 2, 2014 - hi i am having a acript for which i need to skip the execution of some lines and to continue with remaining lines for eg script.sh rm text for i in * do . . . . . if [x = y] then rm i want to skip the execution o…
🌐
Syteca
syteca.com › docs › the-command-output-skipping-parameter
The Command Output Skipping Parameter
To skip the output of specific commands, on the Editing Client / Editing Client Group page, select the Monitoring [Linux] tab, and in the Command Output Skipping section (at the bottom), enter the required commands (in the Commands field), separating them by semicolons.
🌐
Michael Currin
michaelcurrin.github.io › dev-cheatsheets › cheatsheets › shell › scripting › skip-errors.html
Skip errors | Dev Cheatsheets
Note, you could use ; instead, but then the second bit will always run, which is unnecessary. Here we check if packages are up to date (code 0) or outdated (code 1). Also output is silenced. if npm outdated > /dev/null; then echo 'Nothing to update' exit 0 fi echo 'Upgrading' npm update · Here capturing the output. And assuming set -e not set, so that a command can fail and its exit status can be used.
Find elsewhere
🌐
LinuxQuestions.org
linuxquestions.org › questions › linux-newbie-8 › shell-script-next-skip-do-nothing-596682
Shell script next/skip/do nothing
Good Day, Hod do I tell shell script to go to next step if condition becomes true. like Code: declare count[9]=( 2 3 4 5 6 7 7 5 2) for (i=0;1
🌐
Unix.com
unix.com › shell programming and scripting
go to / skip in script - Shell Programming and Scripting - Unix Linux Community
November 4, 2009 - Hi all I have some script like this #!/bin/bash mv /tmp/file1 tmp/file2 if [[ $? -eq 0 ]] ; then cp /tmp/filetest/ tmp/file3 if [[ $? -eq 0 ]] then echo "succes" else echo "failed" fi else echo "failed" fi i didn't try to see if it's work, the thing is that i don't care if it's failed in phase one or two, is there any way to short this written without all this echo somethis like this #!/bin/bash mv /tmp/file1 tmp/file2 if [[ $? -eq 0 ]] ; then cp /tmp/file...
🌐
Unix.com
unix.com › linux and unix-like › linux
Go to a line of code , skip few lines of code - Linux - Unix Linux Community
December 25, 2012 - Hi , I have a code where i am using a infinite while loop . some thing like below while [ 2 -gt 1 ] do if [ logic ] then #go to line 20 fi command 1; command 2; #line 20: sleep 34; done; Now i want that if my logic enters the if loop it should go directly to sleep 34 ; and i.e. skip command ...
🌐
Fabian Lee
fabianlee.org › 2020 › 01 › 18 › bash-skipping-lines-at-the-top-or-bottom-of-a-stream
Bash: Skipping lines at the top or bottom of a stream | Fabian Lee : Software Engineer
January 19, 2020 - Using head to get the first lines of a stream, and tail to get the last lines in a stream is intuitive. But if you need to skip the first few lines of a stream, then you use tail “-n +k” syntax. And to skip the last lines of a stream head ...
🌐
GNU Project
sourceware.org › gdb › current › onlinedocs › gdb.html › Skipping-Over-Functions-and-Files.html
Skipping Over Functions and Files (Debugging with GDB)
See for example ‘man 7 glob’ on GNU/Linux systems for a description of glob-style patterns. ... The basic form of the skip command takes zero or more options that specify what to skip. The options argument is any useful combination of the following: ... Functions in file will be skipped ...
🌐
Skip
skip.dev › docs › skip-cli
Skip CLI Reference | Skip
The Skip command-line interface (CLI) is a tool that can be run from the terminal on macOS, Linux, or Windows.
🌐
GitHub
github.com › clintwebb › skip
GitHub - clintwebb/skip: Simple command-line tool to skip lines. · GitHub
Skip is a simple tool useful mostly for bash scripting and command-line operations. n: Skip 'n' number of lines, and then output the rest · +n: Do NOT Skip 'n' number of lines. Means specifically to output them. ... header: Skip any lines at the start of the stream until a blank line is determined, and then will output the rest · before "string": Skip any lines until the specified "string" is matched at the beginning of a line, then will output the rest (including line that matched unless 1 is the next parameter)
Author   clintwebb