Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ksh programming: String Manipulation?

Status
Not open for further replies.

TheElephantMan

Programmer
Jun 18, 2004
42
US
Hello, all.

I am brand new to ksh programming and as a programming exercise I decided to create a little script that takes a single string (of a word) as an input and then outputs the word in Pig Latin.

The main notions of my logic are fine, I just seem to have run into an impasse with string manipulation. Specifically, I cannot seem to find a function or command that mimics the classic substring function.

Does such a thing exist in ksh, and how do I invoke it?

Thanks tons, in advance.

TEM
 
man ksh
man expr

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Substring parameter expansion is available in versions of ksh newer than the 11/16/88 version.

You can check your version date with ESC Crtl-V or just Ctrl-V, depending on which built-in editor is in use.

If your version is new enough, then ${parameter:eek:ffset:length} is the form of expansion you want. Offset is zero based, and length can be left off if you want the rest of the string from that offset.

If you don't already have it, I recommend The New KornShell Command and Programming Language, by Morris I. Bolsky and David G. Korn as a reference and tutorial for anyone using ksh.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top