Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

String substring?

Posted on 2007-11-14
4
Medium Priority
?
4,106 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 120 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 80 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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 …
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…

609 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