The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to write pseudo code hanaveenkumar Shell Programming and Scripting 1 05-14-2009 02:17 AM
How to write a code in C to search a file krishna_sicsr High Level Programming 6 08-04-2008 06:07 PM
AWK deifnition and some small code explanation amatuer_lee_3 Shell Programming and Scripting 0 05-17-2008 09:57 PM
small script - get sql output & write into txt happyv Shell Programming and Scripting 2 02-02-2007 11:55 AM
need help to write perl code getdpg Shell Programming and Scripting 0 09-20-2006 09:24 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-16-2009
lkeswar lkeswar is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
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 (permalink)  
Old 06-16-2009
jayan_jay jayan_jay is offline
Registered User
  
 

Join Date: Jul 2008
Location: Chennai
Posts: 40
What have you done to attempt to solve this problem yourself?

Post your sample script, and we'll see how we can assist.
  #3 (permalink)  
Old 06-17-2009
lkeswar lkeswar is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
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 (permalink)  
Old 06-17-2009
rakeshawasthi rakeshawasthi is offline
Registered User
  
 

Join Date: Aug 2004
Location: India
Posts: 379
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.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0