don't know how to implentment as unix sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting don't know how to implentment as unix sh script
# 1  
Old 01-10-2008
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
# 2  
Old 01-10-2008
Assuming you can use bash
Quote:
Originally Posted by ttivanwan@yahoo
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
# 3  
Old 01-10-2008
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
# 4  
Old 01-10-2008
You're mixing awk with sh.
# 5  
Old 01-10-2008
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 ??
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

2. UNIX for Dummies Questions & Answers

Change unix permission when I don't own the file

Hi, A file is transferred from a Windows server(say username : user1) to Unix server via ftp. In unix, the permission of the file for a user, say user2 will be "-rw-r-----". Since the user1 is the owner of the file, user2 is not able to change the file permission using chmod. Is there... (5 Replies)
Discussion started by: merin
5 Replies

3. Filesystems, Disks and Memory

Why we don't need to defrag UNIX FS?

Hi I am wondering which is the reason why there is no need to defrag file system in UNIX and Linux, and in Windows I must defrag it ? (7 Replies)
Discussion started by: solaris_user
7 Replies

4. UNIX for Advanced & Expert Users

don't understand the unix script

if {"$my_ext_type" = MAIN]; then cd $v_sc_dir Filex.SH $v_so_dir\/$v_fr_file Can somebody tell me what does this suggest. I am pretty new to unix and I am getting confused. What i understood from here is If we have a file extension name as MAIN which we have then we change the directory to... (1 Reply)
Discussion started by: pochaman
1 Replies

5. Shell Programming and Scripting

script don't stop

Hello everybody! I am new to this and I am trying to change a script in an open source program that plots some offset vectors and then calls a postscript viewer. I have commented away the call for the postscript viewer but somehow the script doesn't return to the shell prompt. I cant figure out... (3 Replies)
Discussion started by: larne
3 Replies

6. Programming

Why I don't have CC1 in my Unix?

gcc works find in my Unix. But when I want to use cc1, system reports: "bash: cc1: command not found". Any clue? Thank you! (2 Replies)
Discussion started by: meili100
2 Replies

7. UNIX for Dummies Questions & Answers

I don't want to go to jail. so I want to start using unix

I use Mac OSX and have been given all of my video editing software... illegally. I don't want to use it anymore and heard that Unix was the way to go. So that is why I am here. What video editing software is out there for Unix. I think I have Unix. Do I? I am sorry and if all anyone can... (0 Replies)
Discussion started by: moz1979
0 Replies

8. UNIX for Dummies Questions & Answers

which unix?? <donīt know where to post>

Iīm struggling to find a system I like and thatīs not to overwhelming.. Iīve been using Ubuntu/Linux and itīs allright except that itīs pretty buggy and boots extremely slow. Iīm in need of a system that offers good programming features, simple or no x server, fast to boot and STABLE. Donīt care... (2 Replies)
Discussion started by: riwaTNT
2 Replies

9. UNIX for Dummies Questions & Answers

I want to cheaply build my own Linux/Unix PC, but don't know where to start

I want to cheaply build my own PC that will run the latest versions of Linspire, Fedora Core, FreeBSD and Solaris, but I don't know where to start. This PC doesn't have to be particulary fast. It's video performance need not be top notch, however, sound quality and sound performance must rock!... (4 Replies)
Discussion started by: Mr. Nice Guy
4 Replies
Login or Register to Ask a Question