1834207 Members
2559 Online
110066 Solutions
New Discussion

string in script

 
SOLVED
Go to solution

string in script

Hi,

I'm beginning to work on UNIX.
I created a script and i would do for example :

var="AZERTY"

and i want var1="AZ" from var

Can you help me.

Thanks.
Interest HP-UX
1 REPLY 1
Darren Prior
Honored Contributor
Solution

Re: string in script

Hi,

If you want the first 2 characters of the variable then:

var1=$(echo $var | cut -c 1-2)

will do the job.

regards,

Darren.
Calm down. It's only ones and zeros...