LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-22-2005, 08:17 AM   #1
sgracelin
LQ Newbie
 
Registered: Jun 2005
Posts: 10

Rep: Reputation: Disabled
Find a value following a string


I have a requirement that I need to get the value of a variable stored in a file..the content will be as follows..

proc="Agent",clause="-l 444441 -p 222221 -i 191.161.1.71 -t 60 -s 1",rstcnt="3",t="60",-s="0",critical="no",prty="20";

the position of the variables is not fixed..For example -p can come anywhere in the line..If I give -p then it should return me 222221. If I give -i 191.161.1.71 , if I give critical then it should return "no" ie for any string given it should get the next value.

Is it possible to do it in shell script???..Pls give ur inputs..
 
Old 07-22-2005, 09:41 AM   #2
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there,
yep, it is possible to use shell script.
what should be the output of "-s"? it appears twice....
my tip is
*disclaimer : not tested. from the top of my head..
Code:
#!/bin/sh
awk -F "$1" '{print $2}' $your_file_name_here
calling the script like..
Code:
myscript.sh $whatever..
can you figure the rest? post back if you have problems..
regards
slackie1000

Last edited by slackie1000; 07-22-2005 at 09:53 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace string Johng Programming 9 01-13-2010 05:50 AM
Shell script to find a particular string Prasun1 Linux - General 5 08-30-2005 10:23 AM
How to find a string in a directory? iclinux Linux - Newbie 2 07-02-2005 09:20 AM
find repeated characters in a string mcshen Programming 9 02-02-2004 06:43 PM
find a string and write it somewhere eicherlist Programming 11 01-02-2004 11:07 AM


All times are GMT -5. The time now is 05:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration