Hey, geniuses of the world (no--facetious is NOT the word of the day;))!
I was wondering if there's a way to extract a specific portion from a string of characters in UNIX/LINUX. Give me the generic capabilities (assuming they exist) and I'll figure out the small details.
But if you know the unique syntax, I'd prefer to do it in bourne shell and I'm using Linux RedHat Enterprise ver 2.6.9-55.ELsmp (if that makes a diff).
e.g. in SQL Server and I know this is a far cry from Linux, but this is just to demonstrate what I hope to achieve:
they have a substring function:
SELECT SUBSTRING(abcdefgh,4,3)
which produces "def" as a result
abcdefgh = expression, 4 specifies the starting character position, and the three specifies how many characters to extract FROM the starting character position
how, if desired, could I accomplish similar results using UNIX/LINUX?!
hey, man--where can I find documentation on this li'l procedure?! I mean, what are the underpinnings--what made that work?! What function of UNIX allowed you to do that? Is it built in to the echo function or can I use the :#:# function with other commands such as printf?
If you have more information or could direct me, that'd be great.
Your solution worked like a charm though; YOU'RE THE MAN!!!
it's built right into the shell. the ways to use it are endless. it's all in the man pages or associated documentation. Grab a shell programming book or read an online tutorial. shell programming is very powerful as you will see. you can solve most common problems with a mix of shell+awk+sed.
what keywords should I research to find more about the use/features/options of the ":#:#" convention??
e.g. does that feature have a name?!
You know variable expansion covers how the shell interprets variables, but if people don't know the term "expansion", they might query for the wrong things. You get my point...
I've read lots of documentation and have never come across that, I'm thoroughly familiar with sed, my awk knowledge needs to catch up though.
Dude, I really appreciate this technique. It'll be very helpful when extracting certain portions of uniformly-formatted strings and storing to variables.
So if you know of a particular name (keyword) for that string:#:# technique, I'd appreciate it.
It's described under the "Parameter Expansion" section of the shell's man page. So it's fair to assume that "Parameter Expansion" is a good name for it.