?
Solved

striping characters with awk

Posted on 2002-04-19
3
Medium Priority
?
272 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 200 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

800 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