Solved

striping characters with awk

Posted on 2002-04-19
3
262 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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.:

773 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