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 > 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
scripting - write a script that will count the number of times a particular word BigTool4u2 Shell Programming and Scripting 3 06-24-2009 01:46 PM
sql scripting help sam786 Shell Programming and Scripting 3 12-10-2007 12:31 PM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 08:12 AM
scripting guru's pls help me with scripting on AIX thatiprashant Shell Programming and Scripting 1 01-20-2006 07:58 PM
Scripting? woofie What's on Your Mind? 1 03-09-2005 07:03 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-15-2008
praveenbvarrier praveenbvarrier is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 15
ksh scripting help

I have the file as below

server1 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle
server2 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle
server3 yes dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle
server4 yes dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle


When I run below from the shell :-
#FileName=/list.config
#cat $FileName | grep -v "#" | sed -e 's/ / /g' | awk '{print $1,$2}'| grep -w yes| cut -d' ' -f1
server3
server4

Now when I run from the shell script in this way:-
#!/bin/ksh
FileName=/list.config
awkfilter="$1,$2"
filter_string="yes"
temp_str=(cat $FileName | grep -v "#" | sed -e 's/ / /g' | awk '{print '$awk_filter'}' | grep -w "$temp_str1$Filter_String" |cut -d' ' -f1)
echo $temp_str
#######

is not giving the same above output that gave me from the shell.

The set -x for the cat in the script is :-
+ + cat /list.config
+ grep -v #
+ sed -e s/ / /g
+ awk {print $1,$2}
+ cut -d -f1
+ grep -w yes
temp_str=
+ echo



Can somebody please help me out to find why its not working inside the script?

Last edited by praveenbvarrier; 04-15-2008 at 09:48 AM..
  #2 (permalink)  
Old 04-15-2008
praveenbvarrier praveenbvarrier is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 15
NOw that the above problem is solved , I am stuck up with another grep issue,

I replaced the cat like below:-
cat $FileName | grep -v "#" | sed -e 's/ / /g' | awk '{print '$awk_filter'}' | grep -w $Filter_String

this works only if Filter_string has one word , if it has two words like "yes dr" then it gives
grep: 0652-033 Cannot open dr".

Here the grep is not taking the entire content of the $Filter_String to search ,rather it tries to search to search yes in the file dr. How we avoid this.

Last edited by praveenbvarrier; 04-15-2008 at 11:15 AM..
Sponsored Links
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 04:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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