Hi
Thanks for your help.But unfortunately it has to be a UNIX korn shell script as otherwise the production support will not be able to handle any errors.
My sincere apologies for troubling you!
Regards
SRK
Does that mean you have to use only shell builtins only. ?
What is the problem in running perl under ksh ?
Its going to run fine.
If you want the solution only with ksh, won't you allow using other utilities like sed, awk to be used.
Hi
I checked with the Tech Mgr .It has to be in Unix Kshell as the production people are not well versed with Perl
Please see if you can help me
Thanks
Sri
Assuming I understand your requirements, I modified your example file so that
there was good pairs and bad "single lines" in a file, and the below does what
you're looking for.
file to read:
991320070521330000000003|Q13251|A18741|234567890123456
671320070521330000000003|Q13251|A18741|456787654328977
671320070521330000000003|Q13260|A18765|4567890987654321234
471320070521330000000003|Q13260|A18765|2345678901234561
991320070521330000000003|Q23251|A28741|234567890123456
471320070521330000000003|Q23260|A28765|2345678901234561
---------------
script:
#!/usr/bin/ksh
for i in `cat $1 | awk -F\| '$2~/Q/{ print $2 "|" $3 }' | sort | uniq'`
do
LINES=`grep "$i" one | wc -l`
if [[ $LINES -eq 2 ]]; then
grep "$i" one >> goodfile
else
grep "$i" one >> badfile
fi
done
---------------
just need to type in filename you want to sort as argv1
i.e. ./scriptname filename
---------------
2 output files:
more goodfile
991320070521330000000003|Q13251|A18741|234567890123456
671320070521330000000003|Q13251|A18741|456787654328977
671320070521330000000003|Q13260|A18765|4567890987654321234
471320070521330000000003|Q13260|A18765|2345678901234561
more badfile
991320070521330000000003|Q23251|A28741|234567890123456
471320070521330000000003|Q23260|A28765|2345678901234561
---------------
I notice in the example that you added some text to end of lines on badfiles, but didn't give any logic behind what is inserted. You should be able to add whatever logic testing inside the else statement to accomidate that hopefully without a lot of problems.
for its uses the first field and then filters out the output but the OP had requested for something different in which specific Q/A pairs should be available.
I went through a scan of this solution and I don't think this would work !
I doubt this solution,
for its uses the first field and then filters out the output but the OP had requested for something different in which specific Q/A pairs should be available.
I went through a scan of this solution and I don't think this would work !
Matrix, as we all agree, the OP was not and is not really clear in his specification,
thus we can have several different interpretations.
Also, the OP did not even reply yet to let us know if our solution works for him.
In any event, if the OP requires a specific Q/A pairs, here is one possible solution:
I'm assuming columns 2 and 3 are codes, and dependant on those is where it goes. Simple code would be below using IF's to define them and write it out to their respective file with the descriptors..
cat $inputfile | awk '
BEGIN{
FS="|"
}
{
if [ $2 == "Q13260" && $3 == "A18741" ]
printf("%s >> Good Transaction\n",$0) >> "/u/data/goodfile.log"
Hi all,
$ echo $SHELL
/bin/bash
Requirement - How to pass oracle sql script as argument to unix shell script?
$ ./output.sh users.sql
Below are the shell scripts and the oracle sql file in the same folder.
Shell Script
$ cat output.sh
#!/bin/bash
.... (7 Replies)
Hi team,
My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server.
I have completed the first part i.e From windows to using to unix server with the help of psftp.exe
code:
psftp user@host -pw password <... (1 Reply)
Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh.
Thanks in advance (2 Replies)
Hi,
Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting?
If so what command i need to use.
thanks in advance. (1 Reply)
Hi,
I need help urgently for following issue. Pls help me to resolve this issue.
I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql)
I given... (6 Replies)
Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files..
Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this?
Please tell me... (2 Replies)
I want to create an automated script which is called by another maually executed script.
The condition is that the no one should be able to manually execute the automated script.
The automated script can be on the same machine or it can be on a remote machine.
Can any one suggest a check in the... (1 Reply)
Hi ,
I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell.
So scenario is that
- I need to have one shell script which is ran as a part of crontab
- in this shell script I need to do a... (2 Replies)