LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices



Reply
 
Search this Thread
Old 01-16-2013, 10:20 PM   #1
rajachan
LQ Newbie
 
Registered: Jan 2013
Posts: 10

Rep: Reputation: Disabled
Exclamation AIX Shell script


hi,

i am doing aix shell scripting for first time.. i am having output file in below foramt.


sql>select data, id, profile from value and someline like this for the querey and the query ends up with semicolon;

data id profile
------------------------
raj 1 system
binu 2 user
ram 3 system


can you please help me to validate the above output file and check if data=binu and id-2 and profile=user then "success"
 
Old 01-17-2013, 06:45 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 281

Rep: Reputation: 118Reputation: 118
Hi there,

Try this:

Code:
grep -q "binu 2 user" outputfile
if [ $? -eq 0 ]
then
  echo "success"
fi
Regards,

Clifford
 
Old 01-18-2013, 09:06 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
"AIX" is an operating system, not a scripting language. What shell are you using?

(Or at least what do you have available for use? Since this is a Linux forum, the posters here are most familiar with bash.)


And please explain your exact requirements more clearly. Your sql query example has three lines of output. Do you need to search that output for an exact user match, as it seems? Or does the output need to match exactly, or what? And what should happen if any of the required strings don't match?


@cliffordw, you can simplify your test like this:

Code:
if grep -q "binu 2 user" outputfile ; then
  echo "success"
fi
Note that this is bourne-style shell syntax (posix-supporting shells like bash or ksh). If the shell is csh-based it would probably be very different.

Also, we can't assume that the AIX version of grep has the same options as the gnu tools. "-q" might not be available. An output redirection may be necessary instead.

Edit: Ok, aix grep does have it, so at least that's not a problem.


PS: please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.

Last edited by David the H.; 01-18-2013 at 09:08 AM. Reason: as stated
 
  


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
AIX shell script to get Hostname from Machine and linux098 Linux - Newbie 4 10-12-2012 10:21 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 10:12 PM
Remote Win Bat File execute Shell Script on AIX Server DriveMeCrazy AIX 5 05-26-2004 07:24 PM


All times are GMT -5. The time now is 03:55 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration