Use cut:
echo 'someletters_12345_moreleters.ext' | cut -d'_' -f 2
More generic:
INPUT='someletters_12345_moreleters.ext' SUBSTRING=$(echo $INPUT| cut -d'_' -f 2) echo $SUBSTRING
Related Posts:
- “[ ]” vs. “[[ ]]” in Bash shell
- Multi-line string with extra space (preserved indentation)
- Multi-line string with extra space (preserved indentation)
- How to trim whitespace from a Bash variable?
- How to trim whitespace from a Bash variable?
- bash : Bad Substitution
- How to convert a string to lower case in Bash?
- How to split one string into multiple strings separated by at least one space in bash shell?
- Extract filename and extension in Bash
- How do I get a substring of a string in Python?
- Substring in excel
- Does Python have a string ‘contains’ substring method?
- What is lexicographical order?
- How do I pause my shell script for a second before continuing?
- How to check whether a string contains a substring in JavaScript?
- How do I split a string on a delimiter in Bash?
- Regex not operator
- working of \n in python [duplicate]
- Regex not operator
- Does Python have a string ‘contains’ substring method?
- Extract a substring using PowerShell
- In the shell, what does ” 2>&1 ” mean?
- Regex not operator
- Ubuntu says “bash: ./program Permission denied” [closed]
- How to compare strings in Bash
- How do I check if a string contains a specific word?
- In the shell, what does ” 2>&1 ” mean?
- How do I use a regex in a shell script?
- How to concatenate string variables in Bash
- -bash: syntax error near unexpected token `)’
- What is the difference between \r\n, \r, and \n? [duplicate]
- How to grep for case insensitive string in a file?
- An example of how to use getopts in bash
- string to string array conversion in java
- Difference between wait and sleep
- What is the difference between \r\n, \r, and \n? [duplicate]
- Check if a string contains a string in C++
- Regex how to match an optional character
- How to remove punctuation in python?
- Replace part of a string with another string
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- Loop through an array of strings in Bash?
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How can I check if a directory exists in a Bash shell script?
- How do I iterate over a range of numbers defined by variables in Bash?
- How do I properly compare strings in C?
- How to remove .html from URL?
- What is the difference between a “line feed” and a “carriage return”?
- How to convert an int to string in C?
- How do I check if a string contains a specific word?
- How do I iterate over a range of numbers defined by variables in Bash?
- “unary operator expected” error in Bash if condition
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
- What does “-ne” mean in bash?
- “sed” command in bash
- How can I declare and use Boolean variables in a shell script?
- How to reload .bashrc settings without logging out and back in again?
- Ignoring upper case and lower case in Java
- How to replace all double quotes to single quotes using jquery?
- How can I declare and use Boolean variables in a shell script?
- How to reload .bash_profile from the command line?
- What is the purpose of “&&” in a shell command?
- Convert character to ASCII numeric value in java
- How to generate random number in Bash?
- Replace one substring for another string in shell script
- How to check if a variable is set in Bash?
- What does strcmp() exactly return in C?
- Generate random string/characters in JavaScript
- How do I split a string on a delimiter in Bash?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- How to get the filename without the extension from a path in Python?
- sprintf like functionality in Python
- How can I compare numbers in Bash?
- What is the difference between String.subString() and String.subSequence()
- Java – removing first character of a string
- C – The %x format specifier
- What is a list in Bash?
- How does String substring work in Swift
- Lua string.format options
- Open and write data to text file using Bash?
- n-grams in python, four, five, six grams?
- How can I count all the lines of code in a directory recursively?
- How can I kill a process by name instead of PID, on Linux?
- Given two directory trees, how can I find out which files differ by content?
- Alphabet range in Python
- Which characters need to be escaped when using Bash?
- How to remove the quotes when reading a variable in jq in shell?
- How to extract the substring between two markers?
- Shell: How to call one shell script from another shell script?
- How can I match a string with a regex in Bash?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- find: missing argument to -exec
- How do I set a variable to the output of a command in Bash?
- ./configure : /bin/sh^M : bad interpreter
- What is the difference between ‘ and ” in JavaScript?
- Center text in fixed-width field with stream manipulators in C++
- C# – Illegal characters in path
- \n or \n in php echo not print [duplicate]
- Is there a TRY CATCH command in Bash
- Mips how to store user input string