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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Formatting of file to an desired one pkondur Shell Programming and Scripting 5 04-01-2008 10:26 PM
chmod not working as desired JamesByars UNIX for Dummies Questions & Answers 2 02-21-2008 10:30 AM
Desired Format ! prasanth_babu HP-UX 1 02-20-2008 07:31 AM
Help me in getting the desired output akash Shell Programming and Scripting 2 12-02-2007 08:27 AM
get the timestamp of a file in desired format sumeet UNIX for Advanced & Expert Users 1 03-08-2007 09:24 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-23-2006
Registered User
 

Join Date: Jul 2006
Posts: 57
Please Read REBORG

Reborg,

Sorry to bother you. I have tried the code you suggested and it's not creating new files after they satisfy the criteria. If any of the files don't satisfy the criteria it should not create the files at all. Please see my output below.



Quote:
+ dev=/biddf/ab6498/dev/ctl
+ cd /biddf/ab6498/dev/ctl
+ echo /biddf/ab6498/dev/ctl
/biddf/ab6498/dev/ctl
+ + date +%Y%m%d
files=CARE01_DLY_???_20060723
+ echo CARE01_DLY_AUS_20060723 CARE01_DLY_MKT_20060723
CARE01_DLY_AUS_20060723 CARE01_DLY_MKT_20060723
+ awk {data[NR] = $0; out=FILENAME "new"; file[NR]=out;} END { if ( FNR
- 2 != $1) { print "error" ; exit 1 } if ( ARGIND == --ARGC ){ for ( i=2
; i < NR; i++ ) { print data[i] > file[i] } close(file[i])}}
CARE01_DLY_AUS_20060723 CARE01_DLY_MKT_20060723

Last edited by mhssatya; 08-17-2006 at 03:48 PM. Reason: Reborg can answer it faster if he sees it!!!!
Reply With Quote
Forum Sponsor
  #2  
Old 07-24-2006
Registered User
 

Join Date: Jul 2006
Posts: 183
Satya,

I see that in your script you are using ARGIND and ARGC which are specific to nawk and gawk languages and it will not work for you if they are not installed on your system. Other than that I think Reborg should help you with the code he wrote.

Thanks
Reply With Quote
  #3  
Old 07-24-2006
Registered User
 

Join Date: Jul 2006
Posts: 57
Thanks Sravan.

Reborg,

I don't have either nawk or gawk installed and hence the script is not working as desired. Is think there is a way to solve this as we got the incorrect output before? Kindly suggest.

I am just getting the name of the files when I run the script. So please help.

Code:

Quote:
#! /usr/bin/ksh
dat='/biddf/ab6498/dev/ctl'
cd $dat
files=CARE01_DLY_???_`date '+%Y%m%d'`


awk '{data[NR] = $0; out=FILENAME "new"; file[NR]=out;} END { if ( FNR - 2 != $1) { print "error" ; exit 1 } if ( ARGIND == --ARGC ){ for ( i=2 ; i < NR; i++ ) { print data[i] > file[i] } close(file[i])}}' $files
Reply With Quote
  #4  
Old 07-24-2006
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,638
Can you post the output of

uname -a again, I think it was HPUX, but am not certain.
Reply With Quote
  #5  
Old 07-24-2006
Registered User
 

Join Date: Jul 2006
Posts: 57
Reborg,

Here is the output of uname -a

HP-UX drwatson B.11.00 B 9000/800 615399343 16-user license
Reply With Quote
  #6  
Old 07-24-2006
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,638
That's what I though, HPUX replaced both awk and nawk with a new version of awk in 11.

This may work, but I don't have a HPUX machine, and don't know exactly how HPUX awk will behave.

Code:
awk '{data[NR] = $0; out=FILENAME "new"; file[NR]=out; records[out]=NR } END { for ( r in records ) { sum += data[records[r]]; print sum } print ARGC, NR, NR - (--ARGC * 2);  if ( sum != NR - (ARGC * 2) ) { print "error" } else {for ( i=2; i < NR; i++ ) { print data[i] > file[i] } close(file[i])}}' $files
Reply With Quote
  #7  
Old 07-24-2006
Registered User
 

Join Date: Jul 2006
Posts: 57
Reborg,

I really salute your skills. Let me give it a try. I will revert back with results.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0