![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regex extraction | abdurrouf | Shell Programming and Scripting | 11 | 06-24-2008 12:48 PM |
| Regex | deepakpv | Shell Programming and Scripting | 6 | 03-28-2007 04:18 AM |
| Regex?? Please help | lunac | UNIX for Dummies Questions & Answers | 7 | 01-30-2007 01:13 PM |
| use of regex on grep | solea | UNIX for Dummies Questions & Answers | 0 | 09-30-2004 11:13 AM |
| sed regex | Shakey21 | UNIX for Dummies Questions & Answers | 4 | 01-31-2002 09:16 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello
I need to make a regex. I have a file myfile, in this file I want to find a number situated after PAYSLOT= Before PAYSLOT is the begining of line (I guess Code:
^ after the number is the end of line (I guess Code:
$ I want to echo this number (I guess Code:
$1 Code:
payslot=`cat $myfile | grep PAYSLOT | awk \^PAYSLOT=($1)$\ ` ![]() |
|
||||
|
Quote:
Code:
payslot=`grep PAYSLOT $myfile | awk -F"=" '{print $NF}'`
Code:
payslot=`grep PAYSLOT $myfile | sed -e 's/^PAYSLOT=\([0123456789]\+\)$/\1/'` |
|
||||
|
Quote:
Code:
payslot=`awk -F"=" '/PAYSLOT/{print $NF}'`
Quote:
|
|
||||
|
Quote:
Also, if you leave out the grep you are assuming that the input file does not contain anything other than the single line starting with "PAYSLOT". The OP does not say that that is the case. Hope this helps |
|
||||
|
Quote:
Code:
awk -F"=" '/^PAYSLOT/{print $NF}' myfile
Quote:
Code:
grep PAYSLOT $myfile | awk -F"=" '{print $NF}'
Code:
awk -F"=" '/PAYSLOT/{ print $NF}' $myfile
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|