Results 1 to 4 of 4
what is the best command to use to parse strings?
I have a variable $str and need to parse this string.
Can you provide an example of the command used ...
- 03-24-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 14
parsing strings
what is the best command to use to parse strings?
I have a variable $str and need to parse this string.
Can you provide an example of the command used to get a substring of $str based on the index values of start and end
- 03-24-2010 #2
This is a feature built into Bash. See this page:
Manipulating Strings
Go to the section called "Substring Extraction".DISTRO=Arch
Registered Linux User #388732
- 03-24-2010 #3Just Joined!
- Join Date
- Feb 2010
- Posts
- 14
is there any other command. that I could use?...the expr is giving me lot of syntax issues....i just copied n pasted many different examples and most of them gave me a syntax error
- 03-24-2010 #4
For a positional substring, you shouldn't need expr at all...
You can use the ${STRING:START:LENGTH} syntax to accomplish this.Code:bricka@eagle ~ $ string="foobar"; echo ${string:3}; echo ${string:2:2} bar obDISTRO=Arch
Registered Linux User #388732


Reply With Quote