You can use string operators:
$ foo=1:2:3:4:5
$ echo ${foo##*:}
5
This trims everything from the front until a ‘:’, greedily.
${foo <-- from variable foo
## <-- greedy front trim
* <-- matches anything
: <-- until the last ':'
}
More Related Contents:
- How do I split a string on a delimiter in Bash?
- How can I remove the extension of a filename in a shell script?
- How to split one string into multiple strings separated by at least one space in bash shell?
- How to make the ‘cut’ command treat same sequental delimiters as one?
- Bash: Parse CSV with quotes, commas and newlines
- How to split a file into equal parts, without breaking individual lines? [duplicate]
- Using cut command to remove multiple columns
- How to strip out all of the links of an HTML file in Bash or grep or batch and store them in a text file
- Difference between single and double quotes in Bash
- An efficient way to transpose a file in Bash
- Usage of :- (colon dash) in bash
- What is the preferred Bash shebang?
- How to use aliases defined in .bashrc in other scripts?
- Bash script compare two date variables [duplicate]
- What is the difference between ${var}, “$var”, and “${var}” in the Bash shell?
- source command not found in sh shell
- How to check if a file contains a specific string using Bash
- How does this bash fork bomb work? [duplicate]
- How to view files in binary from bash?
- Test if a command outputs an empty string
- Unable to forward search Bash history similarly as with CTRL-r
- How to produce cartesian product in bash?
- Looping over arrays, printing both index and value
- Temporarily change current working directory in bash to run a command [duplicate]
- Generating random number between 1 and 10 in Bash Shell Script [duplicate]
- How to break out of a loop in Bash?
- How to assign a glob expression to a variable in a Bash script?
- Access arguments to Bash script inside a function [duplicate]
- What’s the difference between “here string” and echo + pipe
- Show Hexadecimal Numbers Of a File