• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

striping characters with awk

Here is simple script, obviously wants to stripe 2 characters away from front.
...
#!/bin/sh
s="a=222"
d=`awk 'BEGIN{FS="="} {printf $2}' $s`
echo "$d"
...
Please help to put it to work.
And if you can please show other ways to stripe 2 characters from
frond.
Thanks
Matt

0
mativare
Asked:
mativare
1 Solution
 
pluimCommented:
With awk:
#!/bin/ksh

a="s=222"
d=`echo $a | awk 'BEGIN {FS="="} {print $2}'`
echo $d

With cut:
#!/bin/ksh

a="s=222"
d=`echo $a | cut -f2- -d"="`
echo $d

Both these options will strip everything up to the "=" sign.

If you want to remove just two characters, use
#!/bin/ksh

a="s=222"
d=`echo $a | cut -c3-`
echo $d

For a="somename=222", d would then contain "mename=222"
0
 
elfieCommented:
with sed:

echo $a | sed '/^..//'
0
 
mativareAuthor Commented:
Thanks a lot!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now