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
Problem with csh script rahulrathod Shell Programming and Scripting 4 02-21-2008 12:38 PM
script problem tdavenpo Shell Programming and Scripting 3 01-04-2006 04:07 PM
Problem starting a script from a 'main'-script Rakker UNIX for Dummies Questions & Answers 3 06-28-2005 09:12 AM
problem with a script Lestat Shell Programming and Scripting 4 06-13-2005 01:30 PM
problem with ftp script...please help vancouver_joe UNIX for Advanced & Expert Users 2 11-22-2001 07:47 AM

 
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 07-05-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
awk script Problem

I wrote a awk but doesnt work as expected.

The Input File
attached input file
My awk Script

/^......[^*].*EXEC CICS /,/END-EXEC/
{
if ( $0 ~ / LINK / )
{ tsflag=1 }
if ( $0 ~ /EXEC CICS/ && tsflag == 1 )
{print "This is Before EXEC CICS"}
if( $0 ~ /END-EXEC/ && tsflag ==1 )
{ print "This is After END-EXEC" }
};

I wanted to Insert a line before EXEC CICS and One After END-EXEC if it has a word LINK in it
But the Out put comes as follows


attached Otput

The After Print is fine but the Before One also comes after the EXEC CICS{ I didnt know how to put if before }

And the Last chunk
AAAAAA EXEC CICS
AAAAAA ABEND
AAAAAA ABCODE ( AB-CODE )
AAAAAA END-EXEC.

Matches Even if It Doesnt have LINK in it (Dont Know Why)


Need get 2 things working in this.....
1) TO put the Statement before EXEC CICS
2) Prevent it from adding if it Doesnt Contain LINK
Attached Files
File Type: txt inpfile.txt (609 Bytes, 13 views)
File Type: txt output.txt (1.8 KB, 10 views)

Last edited by pbsrinivas; 07-05-2007 at 03:21 AM.. Reason: spaces are getting deleted after posting...
 

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 03:21 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