The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Use ftp command in shell script infyanurag Shell Programming and Scripting 3 02-05-2008 08:06 AM
cd command is not working in my shell script amitrajvarma Shell Programming and Scripting 3 10-03-2007 05:04 AM
how to use cd command in shell script LAKSHMI NARAYAN Shell Programming and Scripting 3 09-09-2007 06:04 AM
vi command in shell script bryan UNIX for Dummies Questions & Answers 2 05-23-2006 07:51 PM
Shell script command dipanrc Shell Programming and Scripting 7 11-29-2005 11:15 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 04-11-2008
lg123 lg123 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 1
shell script command

Hi

I have a text file named information.txt which contains information about Oracle Instances, I want to fetch data's from that text file and want to display an output using shell script.
i.e. when I execute that shell script ,it should read all data's from information.txt and display an output like below.
I willl try explain with an example...
Say i have a file "file" containing..
Instance : DB1,windows
Instance : DB2,unix
Instance : DB3,solaris
Instance : DB4,unix
;;;;;;;;etc


so... my shell script should read the file and display output as
DB1,windows,OK
DB2,unix,OK
DB3,solaris,OK
DB4,unix, OK
;;;;; etc

How do I write this script? Can you tell me ..which command wud be appropriate?
  #2 (permalink)  
Old 04-11-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
check if this is what you want:
Code:
awk '{ print $3 ",OK" }' information.txt
  #3 (permalink)  
Old 04-11-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Does the value "OK" depend on some calculation, or do you just want to wipe the first field and add "OK" at the end on all lines?

Code:
sed -e 's/^Instance : //' -e 's/$/,OK/' file
  #4 (permalink)  
Old 04-11-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by Yogesh Sawant View Post
check if this is what you want:
Code:
awk '{ print $3 ",OK" }' information.txt
Slight modification needed to your command,

check out the last line in the input file

Code:
awk 'length($3) { print $3, "OK" }' filename
Sponsored Links
Closed Thread

Bookmarks

Tags
awk, sed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0