It is currently Tue, 17 May 2022 02:27:02 GMT



 
Author Message
 kornshell programming
Hello,
can anyone help mr with a kornshell script? I have a character "A" as a
string, and I want to make it "B" and then "C". This is easy in any
language like C/C++ but I can't do it in shell-scripting. I've tried
just to: char=(($char+1))
but that didn't work. Please help

* Sent from RemarQ http://www.**-**.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



 Tue, 21 Jan 2003 03:00:00 GMT   
 kornshell programming
lautmannNOlaS...@spray.se.invalid...

for CHAR in A B C D E F
do
        echo $CHAR.dot_delimited_suffix
done

:; cLIeNUX /dev/tty3  02:54:05   /
:;for CHAR in A B C D E F
:;:; do
:;:;         echo $CHAR.dot_delimited_suffix
:;:; done
A.dot_delimited_suffix
B.dot_delimited_suffix
C.dot_delimited_suffix
D.dot_delimited_suffix
E.dot_delimited_suffix
F.dot_delimited_suffix

That's Bourne.
Korn does brace expension? Maybe there's something with that.

r...@clienux.com
www.clienux.com



 Tue, 21 Jan 2003 03:00:00 GMT   
 kornshell programming

You can do it using awk:

$ alph=ABCDEFGHIJKLMNOPQRSTUVWXYZ
$ echo D | awk -v alph=$alph '{print substr(alph,match(alph,$0)+1,1)}'
E

Not great but it works.

--
Cheers,
Ted J. Loeffelholz
Senior Design Engineer
Caterpillar Inc



 Tue, 21 Jan 2003 03:00:00 GMT   
 kornshell programming

function alphanext { # an alpha
  typeset bet="a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z" next
  next=${bet##*/$1/} # strip up to and including the char passed
  next=${next%%/*}   # strip everything after the char found
  echo $next

-- ced

--
Chuck Dillon
Senior Software Engineer
Genetics Computer Group, a subsidiary of Oxford Molecular



 Tue, 21 Jan 2003 03:00:00 GMT   
 kornshell programming

ch='a'
newch=`echo $ch | tr '[a-zA-Z]' '[b-zaB-ZA]'`

Note that that works even under bourne shell.



 Tue, 21 Jan 2003 03:00:00 GMT   
 kornshell programming
Thanks for the sollutions.

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



 Sat, 25 Jan 2003 03:00:00 GMT   
 kornshell programming

Note the subject.

There a many solutions available if you can afford the
overhead of calling another program.

-- ced

--
Chuck Dillon
Senior Software Engineer
Genetics Computer Group, a subsidiary of Oxford Molecular



 Sat, 25 Jan 2003 03:00:00 GMT   
 
   [ 7 post ] 

Similar Threads

1. The /New/ KornShell Command and Programming Language

2. Kornshell (PDKsh) problem

3. Kornshell

4. ?Help - Kornshell problem with validating script argument

5. kornshell logout script for root (UNIXWARE 4.2)

6. Kornshell scripting

7. Calling and display of aliases in a Kornshell script

8. Kornshell Doc


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software