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
Include PERL script with in the unix shell script ganapati UNIX for Dummies Questions & Answers 1 04-29-2008 09:18 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 12:31 PM
FTP script for sending a file from one unix directory to another unix server director raja_1234 Shell Programming and Scripting 1 11-30-2006 04:57 AM
how to convert unix .ksh script to windows .batch script 2.5lt V8 Shell Programming and Scripting 1 11-28-2006 09:52 AM
check in unix shell script so that no one is able to run the script manually adi_bang76 Shell Programming and Scripting 1 11-16-2006 07:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-10-2008
Registered User
 

Join Date: Jan 2008
Posts: 3
don't know how to implentment as unix sh script

for each file if file name like xx*
for each line in a file
if substring(3,6) found in another txt file[ the file just have 1 column but have multiple line]
output to file-a( filename = orginal file + _a)
else
output to file-b( filename = orginal file + _a)
end
Next Line
Reply With Quote
Forum Sponsor
  #2  
Old 01-10-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Assuming you can use bash
Quote:
Originally Posted by ttivanwan@yahoo View Post
for each file if file name like xx*
for each line in a file
See here for how to loop
Quote:
if substring(3,6) found in another txt file[ the file just have 1 column but have multiple line]
See here for substring manipulations
Quote:
output to file-a( filename = orginal file + _a)
else
output to file-b( filename = orginal file + _a)
end
Next Line
use ">>" or ">" to output to file
Reply With Quote
  #3  
Old 01-10-2008
Registered User
 

Join Date: Jan 2008
Posts: 3
don't know what happen

I am new for sh script , i have write some code but cann't compile , please help for seeing what problem? It seem to cannot read another file in awk and I don't confirm....

"XXXX.wip.sh" 24 lines, 471 characters
>findcust.wip.sh
Syntax Error The source line is 7.
The error context is
while >>> read <<< line
awk: 0602-502 The statement cannot be correctly parsed. The source line is 7.
Syntax Error The source line is 8.


awk -v '
BEGIN {FOUND = "N";}

{if (match($0, /\!\$....../))
{checkno = substr($0,3,6);
FOUNDINCUST = "N" ;
while read line
do
{if (FOUNDINCUST="N") && (checkno == $line)
FOUND = "Y";
FOUNDINCUST ="Y";
print $0 ;
}
done < "custfilelist.dat" ;
}
}
{if (match($0, "%%RECORDEND"))
FOUND = "N";}
{if (FOUND =="Y")
print $0 >> "atest.dat" ;}
{if (FOUND =="N")
print $0 >> "btest.dat" ;}
' $SOURCEFILE/TEST*.dat
Reply With Quote
  #4  
Old 01-10-2008
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
You're mixing awk with sh.
Reply With Quote
  #5  
Old 01-10-2008
Registered User
 

Join Date: Jan 2008
Posts: 3
thanks for your reply , it means that I cann't have sh script inside the awk call ? then what should I do to do the objective , should i just use the sh script , not use the awk to do it , any code sample that is doing similar things ??
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 07:25 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