07-10-2007
hi,
I'm not sure whether if conditional statement correct or not? Please advise
Basically, if the field 2 exist and with value , it will be update set as cust_alt_fax column and if field 3 exist and with value, update set as cust_alt_fax , else field 4 exist and with value, update set as cust_alt_fax column
Quote:
for mFile in x???
do
# echo "Now working with file "$mFile" at "`date`
mOutFile=$mFile".sql"
while read mLine
do
_msisdn=$(echo $mLine | cut -d "|" -f 1)
_cust_ic=$(echo $mLine | cut -d "|" -f 2)
_cust_other_ic=$(echo $mLine | cut -d "|" -f 3)
_cust_pass=$(echo $mLine | cut -d "|" -f 4)
_cust_name=$(echo $mLine | cut -d "|" -f 5)
_cust_street1=$(echo $mLine | cut -d "|" -f 6)
_cust_street2=$(echo $mLine | cut -d "|" -f 7)
_cust_post=$(echo $mLine | cut -d "|" -f 8)
if [ -n "wc -l $_cust_ic" ] ; then
echo "UPDATE customer SET cust_alt_fax='$_cust_ic',cust_name='$_cust_name',cust_street_1='$_cust_street1',cust_street_2='$_cus t_street2'
,cust_add_pcode='$_cust_post',chk_upd_dt=CURRENT" >> $mOutFile
echo "WHERE cust_msisdn='$_msisdn';" >> $mOutFile
elif [ -n "wc -l $_cust_other_ic" ] ; then
echo "UPDATE customer SET cust_alt_fax='$_cust_other_ic',cust_name='$_cust_name',cust_street_1='$_cust_street1',cust_street_2= '$_cust_st
reet2',cust_add_pcode='$_cust_post',chk_upd_dt=CURRENT" >> $mOutFile
echo "WHERE cust_msisdn='$_msisdn';" >> $mOutFile
else
echo "UPDATE customer SET cust_alt_fax='$_cust_pass',cust_name='$_cust_name',cust_street_1='$_cust_street1',cust_street_2='$_c ust_street
2',cust_add_pcode='$_cust_post',chk_upd_dt=CURRENT" >> $mOutFile
echo "WHERE cust_msisdn='$_msisdn';" >> $mOutFile
fi
done < $mFile
done
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to generate a test data file by reading inputs from multiple files.
A sample pseudo code for this program to read from three files and write to a output file would be like:
open(OUTPUTFILE, "data");
open(INFILE1, "data1");
open(INFILE2, "data2");
open(INFILE3, "data3");
... (1 Reply)
Discussion started by: jyotipg
1 Replies
2. Shell Programming and Scripting
Hi all,
I have a requirement where i have to read multiple files using Shell Script in Korn Shell.
each file will have the 3rd line as the amount field, i have to read this amount field and sum it for all the files.
any idea on how to achieve this?? (i think i can achieve it using a loop,... (9 Replies)
Discussion started by: nvuradi
9 Replies
3. Shell Programming and Scripting
Hi,
Can any one tell me if i can read two files in a shell script...
My actual requirement is to read the 1st text file and parse it to get the file code and use this file code to retrieve data from database and print the fetched data in the 2nd text file (I have parsed it and printed the... (2 Replies)
Discussion started by: funonnet
2 Replies
4. Shell Programming and Scripting
Hi all,
I would like to simply read a file which lists a number of pathnames and files, then search and replace key strings using a few vi commands:
:1,$s/search_str/replace_str/g<return>
but I am not sure how to automate the <return> of these vis commands when I am putting this in a... (8 Replies)
Discussion started by: cyberfrog
8 Replies
5. Shell Programming and Scripting
Hi All,
there is a script that reads multiple files in a directory starting with CTG_TMPxx where xx is an integer number.
i have a problem in readin the last file. For example, if there are 10 files in that directory, 9 files are read and processed. but the 10th file, its saying as cannot read... (1 Reply)
Discussion started by: vkca
1 Replies
6. UNIX for Advanced & Expert Users
Hi folks
I have a situation where I am trying to use awk to compute mean and standard deviation for a variable that spans across multiple files. The layout of each file is same and arranged in 3 columns and uses comma as a delimiter.
File1 layout:
col1,col2,col3
0,0-1,0.2345... (13 Replies)
Discussion started by: scandy
13 Replies
7. Shell Programming and Scripting
I am trying to create a script which will read 2 files and use the lines of file 1 for each line on file 2.
here's my sample code
cat $SBox |
while read line
do
cat $Date |
while read line
do $SCRIPTEXE <line from first file> $2 <line from 2nd file>
... (12 Replies)
Discussion started by: khestoi
12 Replies
8. UNIX for Dummies Questions & Answers
Hi, is there a ways to read multiple files in a single awk command?
For example:
awk -f awk_script file1 file2 file3
I've google it, most of them suggest using FNR. But I don't understand how it works. It will be a great help if someone able to explain it in simple term with some example. (4 Replies)
Discussion started by: KCApple
4 Replies
9. Shell Programming and Scripting
I have 7 text files of varying sizes for each month of System Maintenance done during the 2013 calendar year (Jan. 134 jobs, Feb. 84 jobs, Apr. 594 jobs, May 158 jobs, July 69 jobs, Aug. 1 job, Oct. 102 jobs) and I have another text file which contains everything from those 7 files. Each of the... (8 Replies)
Discussion started by: CyberOptiq
8 Replies
10. UNIX for Beginners Questions & Answers
How to read multiple files at simultaneously? (1 Reply)
Discussion started by: Priyanka_M
1 Replies
echo(3XCURSES) X/Open Curses Library Functions echo(3XCURSES)
NAME
echo, noecho - enable/disable terminal echo
SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib
-R /usr/xpg4/lib -lcurses [ library... ]
c89 [ flag... ] file... -lcurses [ library... ]
#include <curses.h>
int echo(void);
int noecho(void);
DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially,
curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft-
ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined.
RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR.
ERRORS
No errors are defined.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Unsafe |
+-----------------------------+-----------------------------+
SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5)
SunOS 5.10 5 Jun 2002 echo(3XCURSES)