sed command using the DATE value in Oracle


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command using the DATE value in Oracle
# 1  
Old 09-12-2005
sed command using the DATE value in Oracle

Hi all,

I am using the SQL Loader in Oracle for my data loading.
So i create dynamic control script in unix. I replace the variables with input data in control file using the sed command. The sed commands works fine for the character data, but gives me error on the DATE value.

sed "s/\#BATCH_LOAD_ID\#/${BATCH_LOAD_ID}/
s/\#JOB_PROCESS_ID\#/${JOB_PROCESS_ID}/
s/\#EXTRACT_DATE_FROM\#/${EXTRACT_DATE_FROM}/
s/\#FILENAME\#/${FILENAME}/" $SCRIPTDIR/bulkloadctrl.ctl >> $WORKDIR/$CTLNAME.ctl

In the above, the problem comes for extract_date_from. I will be having the input as EXTRACT_DATE_FROM='08/09/2005 12:30'.

Here i get error saying that EXTRACT_DATE_FROM cant be parsed. I guess the problem is bcos of "/" available in my date format, as that is the control character in sed command. But i am not sure how to resolve it. I have tried using escape sequence "\", but i couldnt find solution. EXTRACT_DATE_FROM is passed as an Input parameter to the shell script.

Any help will be of great use to me.

Thanks,
Utham
# 2  
Old 09-12-2005
before inserting the '08/09/2005 12:30' insert '\' so the input string should be:

'08\/09\/2005'

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies

2. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

3. Shell Programming and Scripting

sed command to replace slash in date format only

Hello experts. I haven't been able to find a solution for this using the sed command. I only want to replace the forward slash with string "FW_SLASH" only if there's a number right after the slash while preserving the original number. I have a file containing 2 entries: Original File:... (5 Replies)
Discussion started by: pchang
5 Replies

4. Shell Programming and Scripting

Display date in mm/dd/yy format in sed command

Hi All, Following is my issue. $MAIL_DOC = test.txt test.txt contains the following text . This process was executed in the %INSTANCE% instance on %RUNDATE%. I am trying to execute the following script var=`echo $ORACLE_SID | tr ` NOW=$(date +"%D") sed -e... (3 Replies)
Discussion started by: megha2525
3 Replies

5. Shell Programming and Scripting

Using sed command replace date variable in unix

I need to use a shell script, using sed command how to replace date variable value in following format. 04/18/2012 11:38:55 Because the sed is treating the '/' as a parameter instead of the value of a variable, and hence there is the message as sed: command garbled: s/insert/04/18/2012... (9 Replies)
Discussion started by: jannusuresh
9 Replies

6. Shell Programming and Scripting

Calculating expiry date using date,sed,grep

Hi, I would greatly appreciate it if someone can help me with my problem. I have a crawler which collects spam URLs everyday & this data needs to be published in a blacklist. Here's the catch: The "Time To Live" (TTL) for each URL is 3 months (or whatever for that matter). If i see the... (5 Replies)
Discussion started by: r4v3n
5 Replies

7. Shell Programming and Scripting

Filter date and time form a file using sed command

I want to filter out the date and time from this line in a file. How to do this using sed command. on Tue Apr 19 00:48:29 2011 (12 Replies)
Discussion started by: vineet.dhingra
12 Replies

8. Shell Programming and Scripting

Format of SED command to change a date

I have a website. I have a directory within it with over a hundred .html files. I need to change a date within every file. I don't have an easy way to find/replace. I need to change 10/31 to 11/30 on every single page at once. I tried the command below but it didn't work. Obviously I don't know... (3 Replies)
Discussion started by: ijustsawmars
3 Replies

9. Shell Programming and Scripting

sed does not allow date command

Hi, I wanted to perform a substitution using 'sed' in my script. I issue the below command sed -i 's/DATE_TIME = .*/DATE_TIME ='`date`'/' file1.txt but it fails with the below error: sed: -e expression #1, char 43: unterminated `s' command using a debug option in my script i got this ... (5 Replies)
Discussion started by: neil_19187
5 Replies

10. Shell Programming and Scripting

Separate date timestamp use awk or sed command ?

Hi, I have logfile like this : Actually the format is date format : yyyymmddHHMMSS and i want the log become this format yyyy-mm-dd HH:MM:SS for example 2009-07-19 11:46:52 Can somebody help me ? Thanks in advance (3 Replies)
Discussion started by: justbow
3 Replies
Login or Register to Ask a Question