Operating System - HP-UX
1832977 Members
3351 Online
110048 Solutions
New Discussion

String Manipulation in csh

 
Vinesh Dhevcharran
Occasional Advisor

String Manipulation in csh

Hi,

I can use the SUBSTR feature in SQL to examine say, the first 3 characters of a varaible. e.g SUBSTR (variable, 1, 3)

How can I do this in the csh?

Many Thanks
Vinesh
2 REPLIES 2
Robin Wakefield
Honored Contributor

Re: String Manipulation in csh

Hi Vinesh,

I'd use awk:

# set A=abcdefghi
# set B=`echo $A|awk '{print substr($0, 3, 2)}'`
# echo $B
cd

Rgds, Robin
Leif Halvarsson_2
Honored Contributor

Re: String Manipulation in csh

Hi
set a="abcdefgh"
set b=`echo $a |cut -c 1-3`