I want to find a linux command that can return a part of the string. In most programming languages, it’s the substr() function. Does bash have any command that can be used for this purpose. I want to be able to do something like this… substr 'abcdefg' 2 3 – prints cde.
Subsequent similar question:
If you are looking for a shell utility to do something like that, you can use the
cutcommand.To take your example, try:
which yields
Where
-cN-Mtells the cut command to return columnsNtoM, inclusive.