The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
file reading through shell script Dip Shell Programming and Scripting 4 10-21-2008 11:10 PM
Reading data from a file through shell script Dip Shell Programming and Scripting 2 10-20-2008 01:51 PM
Shell Script -- problem reading backslash(\)!! rossi143 Shell Programming and Scripting 2 04-04-2007 03:52 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
Reading a CSV file into shell variables problem multidogzoomom Shell Programming and Scripting 6 10-11-2005 05:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-24-2008
Dip Dip is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
File reading problem via shell script

Hi,

Data file named parameter contains :

DB=y
Alter_def.sql
Create_abc.sql

SQL=y
database.sql
my_data.sql

To read this file I use

var_sql=$(awk -F= '$1 == "SQL" { print $2 }' parameter.txt)
if [ $var_sql = "y" -o $var_sql = "Y" ]
then
sql_f_name=`grep "\.sql" parameter.txt`
echo $sql_f_name
fi

So this code returns all the file name. But I want only
database.sql
my_data.sql

these two file. Can any one suggesst me how can I get the desired result
without changing the search string(`grep "\.sql" parameter.txt`).
  #2 (permalink)  
Old 10-24-2008
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
All you need is:
(use nawk or /usr/xpg4/bin/awk on Solaris)


Code:
awk '/SQL=[Yy]/&&sub(/ *[^ \n]*\n/,"")' RS= parameter.txt

  #3 (permalink)  
Old 10-24-2008
Dip Dip is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
Thanks radoulov....it's working fine
Closed Thread

Bookmarks

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 02:42 PM.


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