Solved

striping characters with awk

Posted on 2002-04-19
3
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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!

Question has a verified solution.

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

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 …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

705 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