Solved

String substring?

Posted on 2007-11-14
4
4,084 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Utilizing an array to gracefully append to a list of EmailAddresses
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

705 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