To remove the last item from the array you could use something like this:
#!/bin/bash
length=$(($#-1))
array=${@:1:$length}
echo $array
Even shorter way:
array=${@:1:$#-1}
But arays are a Bashism, try avoid using them :(.
More Related Contents:
- Passing parameters to a Bash function
- Is mixing getopts with positional parameters possible?
- Echo newline in Bash prints literal \n
- In the shell, what does ” 2>&1 ” mean?
- What is the difference between $(command) and `command` in shell programming?
- ssh breaks out of while-loop in bash [duplicate]
- Remove a fixed prefix/suffix from a string in Bash
- I just assigned a variable, but echo $variable shows something else
- Change the current directory from a Bash script
- Bash how do you capture stderr to a variable? [duplicate]
- Variable containing multiple args with quotes in Bash
- Should aliases go in .bashrc or .bash_profile? [duplicate]
- How to read user input into a variable in Bash?
- How to provide password to a command that prompts for one in bash?
- Deleting lines from one file which are in another file
- source command not found in sh shell
- How to check if a file contains a specific string using Bash
- VSCode Change Default Terminal
- How to enter ssh password using bash? [duplicate]
- What is a unix command for deleting the first N characters of a line?
- How do I escape slashes and double and single quotes in sed?
- How to suppress variable substitution in bash heredocs
- Error message on Terminal launch [duplicate]
- Exit when one process in pipe fails
- How to split a file into equal parts, without breaking individual lines? [duplicate]
- Jenkins pipeline sh fail with “cannot run program nohup” on windows
- Translating OS X Bash Script for Windows
- How to redirect a program that writes to tty?
- What is the proper way to test a Bash function’s return value?
- How to loop over files in natural order in Bash?