![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Match words | moutaz1983 | Shell Programming and Scripting | 8 | 01-07-2008 06:26 AM |
| Dynamic SQl in KSH | kousikan | Shell Programming and Scripting | 2 | 03-18-2007 12:12 PM |
| how to dynamic DNS | bondoq | Linux | 1 | 11-14-2006 10:34 AM |
| Dynamic DNS | [MA]Flying_Meat | OS X (Apple) | 0 | 12-06-2005 09:07 PM |
| dynamic pid? | yls177 | UNIX for Dummies Questions & Answers | 2 | 12-17-2002 08:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Give a try,
Code:
#! /usr/bin/perl
$inpFile=$ARGV[0];
$searchStr=$ARGV[1];
open (INP,"<$inpFile") || die "Unable to open INPFILE::$inpFile\n";
while (<INP>) {
$_ =~ s/\x0a|\x0d//g;
@inpTag = split(/\|/,$_);
foreach $value ( @inpTag ) {
($key,$val) = (split ( /=/,$value ));
if ( $key =~ /\b$searchStr\b/ ) {
print "$key= $val\n";
}
}
}
close (INP);
|
|
||||
|
Quote:
code is this ; cat inputfile |awk -F'|' -v srchname=$1 ' $1 ~ srchname {print $1}; $2 ~ srchname {print $2};$3 ~ srchname {print $3};$4 ~ srchname {print $4}; $5 ~ srchname {print $5};$6 ~ srchname {print $6}' the first $1 is command line parameter comes from outside the script. so you can use your script this way from command line or call from an another program ; myscript FILE_TYPE or myscript FILE_DESC etc. Last edited by fazliturk; 08-17-2007 at 09:48 AM.. |
|
|||||
|
hey fazliturk,
thanx a lot...but if the field is going to change i.e. might be increased from 6 to 7 then , in real time it is not feasible to change the query to add one line $7 ~ srchname {print $7} !!!!!! So i want irrespective of all the changes to i/p file, that we can think of, it should give us the o/p of the proper search value....but anyway thanx a lot. lorcan, i tried your one it works fine , with some modification according to my requirement ....But still can we have some more modularized one...using AWK or SED. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|