Always on the radar...


 
Thread Tools Search this Thread
The Lounge What is on Your Mind? Always on the radar...
# 1  
Old 01-30-2016
Always on the radar...

Hi guys...

I have been doing some coding for ADE for the AMIGA 1200, a UNIX package that has the gcc suite, ksh88 as the shell and a large subset of transient and resident commands.

Well I got stuck on this:-
somesubstring=${somestring:x:y}

After some searching I was steered here to this:-

I would like to say thanks to Franklin52 for such a simple answer as the locked thread will not allow me to press the 'Thanks' button...

From the Google POV this site is 'always on the radar' when I am searching for odd stuff...

So thanks Franklin52...

Last edited by Scrutinizer; 01-31-2016 at 05:37 AM..
These 2 Users Gave Thanks to wisecracker For This Post:
# 2  
Old 01-31-2016
Good to hear. Perhaps one of the nice things about unix.com is that with regards to shell scripting, there usually is mix of code suggestions: short, one-line versions that are particularly suited for use on the command line and more elaborate versions that are perhaps more suited for scripts. In the thread you mentioned the version by hergp is quite more efficient and fast and more suited for scripts, whereas I think franklin52's version would be the more practical and easy to read-and-remember version for the command line.

And sometimes there are short versions that are really well suited for either type of application...

Last edited by Scrutinizer; 01-31-2016 at 05:37 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 02-03-2016
Quote:
Originally Posted by wisecracker
Well I got stuck on this:-
somesubstring=${somestring:x:y}
This variable expansion is IIRC only valid in ksh93, not in ksh88. In ksh88 you can do the following, though:

Code:
x="abcde"

while [ -n "$x" ] ; do
     first="${x%${x#?}}"
     rest="${x#?}"

     print - "first: $first    rest: $rest"

     x="$rest"
done

It is quite easy to build a substring-function around this.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

save weather radar to local time-named file every 15 minutes

I think I can do this myself now, but I am always amazed by how people can do things cleaner and simpler than I end up doing... Using cron, I want to save the image found at: http://radar.weather.gov/ridge/Conus/RadarImg/centgrtlakes.gif every 15 minutes to a local file , such as ... (1 Reply)
Discussion started by: brucewestfall
1 Replies
Login or Register to Ask a Question