Solved

striping characters with awk

Posted on 2002-04-19
3
256 Views
Last Modified: 2010-04-21
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
Comment
Question by:mativare
3 Comments
 
LVL 4

Accepted Solution

by:
pluim earned 50 total points
ID: 6954315
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
 
LVL 3

Expert Comment

by:elfie
ID: 6954452
with sed:

echo $a | sed '/^..//'
0
 
LVL 1

Author Comment

by:mativare
ID: 6954640
Thanks a lot!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now