Need small help to write the code in unix

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Need small help to write the code in unix
# 1  
Old 06-16-2009
Need small help to write the code in unix

Hi all,

I get data-files which has a particular identified on the 1st record( header ), based on which I've to load a constant for the 1st column of every row. How do I set in the control file using unix shell script.

Appreciate if someone can give me some directions on this.


Thanks in advance
# 2  
Old 06-16-2009
What have you done to attempt to solve this problem yourself?

Post your sample script, and we'll see how we can assist.
# 3  
Old 06-17-2009
Need small help to write the code in unix

Hi,

I tried with the shell script but it is not loading into table for the below script

#!/bin/bash

#export custno=""

custno=$(awk -F"," '{print NR " " $3}' 'datafile.txt' | grep 1 | cut -d" " -f2)
sed 's/#x#/'$custno'/g' 'ctrl.ctl'

Below is the data file(datafile.txt)

sno,sNAME,35642,reactflag
1,KIRAN,KUMAR
2,SURESH,KUMAR
3,MADHU,VARIGONDA

Here is the control file(ctrl.ctl)
options(skip =1)
LOAD DATA
INFILE 'datafile.txt'
TRUNCATE INTO TABLE LOADER_TEST
FIELDS TERMINATED BY ','
TRAILING NULLCOLS (
sno Integer external,
sname char(50),
custno char(50) CONSTANT '#x#',
reactflag char(50)
)

Please help me in advance
# 4  
Old 06-17-2009
What is the error are you getting?
Quote:
custno=$(awk -F"," '{print NR " " $3}' 'datafile.txt' | grep 1 | cut -d" " -f2)
Not a good way...
Code:
custno=`head -1 'datafile.txt'  | cut -d"," -f3`

was sufficient.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

Number of Small Forum Code Changes (TODO List Items)

In the past few days have I have done a lot of code cleanup work in various categories, including faster page loading and bug fixes: Move countless inline style directives to external CSS stylesheets for key pages (faster page loading) Fixed bug in member panel going between desktop and... (6 Replies)
Discussion started by: Neo
6 Replies

2. UNIX for Advanced & Expert Users

Small database that can be bundled with UNIX

Hi All, I am working on a file transfer tool between unix servers. for this i am looking for a small database which is free and compatible with all unix OS and can be bundled in a package with other scripts. Any suggestions (8 Replies)
Discussion started by: Jcpratap
8 Replies

3. Shell Programming and Scripting

Write a small shell script

Hello Forum members, Have a nice day. I have to write a script for the following below scenario. There are 3 applications located in home directory(ie xyz/app) which have multiple directories and files of diff format(.sh,log,other formats). Case 1: I have to find the hardcoded... (8 Replies)
Discussion started by: rajkumar_g
8 Replies

4. Shell Programming and Scripting

AWK deifnition and some small code explanation

Could someone give me a quick simple explanation for the AWK command. And also help me to explain the code i have made. I have made some general comments about it myself. I was wondering if people could help me with the rest: awk -F'' 'END { fmt = "%-20s\t%s\t%s\n" ... (0 Replies)
Discussion started by: amatuer_lee_3
0 Replies

5. Programming

execution small C++ program in UNIX

Hi my friends I am beginner unix programmer I have written small c++ program in text editor and I have change it mode to 555 to make it executable file to use it in unix O.P. #include<iostream.h> main() { cout<<"Hello World"; } but some syntax erroe came for << can any one help... (5 Replies)
Discussion started by: bintaleb
5 Replies

6. Shell Programming and Scripting

small script - get sql output & write into txt

Hi, how can I write a small script to run the following statement and output the result into check_result.txt select /*+RULE*/ tapname from typetbl where tapname like 'AA%' and rejectcode=9; Normally, I just type sql and get into SQL> (2 Replies)
Discussion started by: happyv
2 Replies

7. Shell Programming and Scripting

Small UNIX problem

I have a shell script that carries out an extraction process as follows: For a given input file dummy which looks like the following: a.txt a 1 a 2 xnzbcnzbxcbzxncbmnzxbcmzx 546 456 45 5 6 56 a 3 b.txt b1 b2 (1 Reply)
Discussion started by: nbvcxzdz
1 Replies

8. UNIX for Dummies Questions & Answers

unix on a small drive?

has any body put freebsd on a drive smaller than 80megs? (4 Replies)
Discussion started by: silverraindog
4 Replies

9. UNIX for Dummies Questions & Answers

small unix!

i'm looking to put a very minimal unix on a 386 i just acquired. it needs to be downloadable and i need to install it using 3.5 floppies! thanks for suggestions, -nydel (4 Replies)
Discussion started by: nydel
4 Replies
Login or Register to Ask a Question