The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script problems to do cleansing_flame Shell Programming and Scripting 0 11-27-2007 09:19 AM
Problems with an if/then loop within a script lodey Shell Programming and Scripting 3 09-18-2007 03:45 AM
Stock script problems hinch UNIX for Dummies Questions & Answers 1 05-24-2006 03:48 AM
Problems with Perl/KSH Web Log Script mmanders Shell Programming and Scripting 3 05-03-2006 07:32 AM
having ksh script problems jerzey4life UNIX for Dummies Questions & Answers 4 09-22-2001 05:39 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-29-2004
hellsd hellsd is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 20
script problems

Hi,

Here is an example of a problem I have:

File2: contain the following lines:
a^ aaa^aa aa^~
b^ bbb^bb bb^~
c^ ccc^cc cc^~
d^ dddd^dd dd^~

File1: contain the following lines:
b^ bbb^bb bb^~
c^ ccc^cc cc^~

I get File2 as input and I want to do as following:

for each line in file2 {
if (line exist in file1) print "! "line
>> output
else
print "+ "line >> output
}

I work on tcsh script:
and this is what I wrote:

cat File2 | awk -F"^" '{if (grep -c $0 file1 == 0) print "- "$0 >> output
else print "! "$0 >> output}'

Expected output:
- a^ aaa^aa aa^~
! b^ bbb^bb bb^~
! c^ ccc^cc cc^~
- d^ dddd^dd dd^~

But I get:
! a^ aaa^aa aa^~
! b^ bbb^bb bb^~
! c^ ccc^cc cc^~
! d^ dddd^dd dd^~

Any idea?

Thanks,
Bando.
 

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 08:14 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