The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to set the File Paths for Inputs and Outputs Amruta Pitkar UNIX for Dummies Questions & Answers 1 10-31-2006 01:19 PM
Checking the format of inputs in a file sendhilmani123 Shell Programming and Scripting 13 05-19-2006 03:12 PM
Validating inputs from a file sendhilmani123 Shell Programming and Scripting 1 05-10-2006 02:49 AM
redirecting serial inputs to a file? guilartec Shell Programming and Scripting 4 02-27-2006 07:30 PM
Inputs from a file sendhil Shell Programming and Scripting 4 02-01-2006 01:48 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2005
Registered User
 

Join Date: Jun 2005
Location: New York City
Posts: 20
Stumble this Post!
Reading in two inputs from a file

Hi all,

I've been assigned the task of modifying a script which reads in names of tables from a list file, exports a 30 days worth of data from these tables, then deletes the table. The list file will now contain a table name and a number next to it indicating how many days to archive. I need to make the script read in the table name, then the number of days to go back, if no number is specified, the default will be 30. Any idea how to start off? Here is some of the current script now:

echo "Start of archive_history.ksh"
TBL_HIST_LIST=$JOB_HOME/archiveHistTbl.list
TBLLIST=$JOB_HOME/archiveTbl.list
DATADIR=/tmp
TODAY=`date +%Y%m%d`

# Set path
PATH="${JOB_HOME}:$HOME/Dear/jobs:${PATH}"

# Set date to delete from
DELDATE=`shift_date.ksh $TODAY -$1`

# For each table, delete based on dt_last_upd_hist
for tbl in `cat $TBL_HIST_LIST`
do
$ORACLE_HOME/bin/exp $DBO_USER/$DB_PASSWORD FILE=$DATADIR/$tbl-${DELDATE}.exp TABLE
S=$tbl QUERY=\"where dt_last_upd_hist \< to_date\(\'$DELDATE\', \'DD-MON-YYYY\'\
)\"
$ORACLE_HOME/bin/sqlplus $DBO_USER/$DB_PASSWORD <<!
delete from $tbl where dt_last_upd_hist < to_date('$DELDATE', 'DD-MON-YYYY');
/
!
end
done

# For each table, delete based on dt_last_upd
for tbl in `cat $TBLLIST`
do
$ORACLE_HOME/bin/exp $DBO_USER/$DBO_PASS FILE=$DATADIR/$tbl-${DELDATE}.exp TABLE
S=$tbl QUERY=\"where dt_last_upd \< to_date\(\'$DELDATE\', \'DD-MON-YYYY\'\)\"
$ORACLE_HOME/bin/sqlplus $DBO_USER/$DBO_PASS <<!
delete from $tbl where dt_last_upd < to_date('$DELDATE', 'DD-MON-YYYY');


Thanks in advance for any help!
Chris

Mods feel free to move this post if its in the wrong forum/topic.

Last edited by MadHatter; 06-29-2005 at 06:41 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-29-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,424
Stumble this Post!
Maybe:
Code:
while read table days ; do
     [[ -z $days ]] && days=30
done < someinputfile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0