Solved

String substring?

Posted on 2007-11-14
4
4,014 Views
Last Modified: 2013-12-26
Everyone:
Good afternoon.  If I wanted the first 4 characters of a string wouldn't I just:

#!/usr/bin/ksh
string=ABCDEJGHIJ
snip=${string:0:4}
echo $snip

I can't seem to make the snip variable contain what I want.  The only progress (see "Knowledge level on this subject :) ) I've been able to make is to set the Start parameter to a negative number which retruns the whole string.

As always many thanks for the help and encouragement.

RC
0
Comment
Question by:Just_RC
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 30 total points
ID: 20282527
I think it depends on your version of ksh as to whether this syntax is supported.

If you have run your script with bash, it will work.
0
 
LVL 2

Author Comment

by:Just_RC
ID: 20283719
Yes...indeed it works in bash.  I"m using M-11/16/88i.  Is there some sort of manual for this version, or any way to see how to do it in this envrionment?
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 20 total points
ID: 20283759
man ksh
0
 
LVL 2

Author Comment

by:Just_RC
ID: 20284028
Thanks everyone...guess I'll skip it (even if its in the book (Rosenblatt & Robbins)  
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now