1752861 Members
4605 Online
108790 Solutions
New Discussion юеВ

Directory specs

 
Allen Karczmarek
Occasional Contributor

Directory specs

I'm writing an automated online backup script for an Oracle database. I have a script that dynamically builds the directory lookups for things such as archive logs. In short my archive log directory is set to something like /exports/archive_logs/
Later in the script I want to do a test like
if [ -f $ARC*]; then blah blah blah.
I need a way to concatenate an asterisk to the end of the directory above to perform the test. Performing it as written above tests for files in the current directory and not in /exports/archive_logs/. Conversely, can you tell me how to remove the asterisk from the end of a string as well. Can this be done with SED?
Thanks!!!
3 REPLIES 3
harry d brown jr
Honored Contributor

Re: Directory specs

Allen,

how about testing/doing something like this:

for i in `find /exports/archive_logs -type f`
do
echo do something with this file $i
done

live free or die
harry
Live Free or Die
Allen Karczmarek
Occasional Contributor

Re: Directory specs

harry,
The problem is that I'm stuck with the / at the end of /exports/archive_logs/.
Yogeeraj_1
Honored Contributor

Re: Directory specs

hi allen,
why can't you just

1. "cd" to the desired directory

2. ls -rt1 ./*.log > backup.list

3. then do any desired operations:

E.g.1:
--------------------------------
tar uvf $DAT `cat backup.list`
--------------------------------

E.g. 2:
----------------------------
for i in `cat backup.list`
do
echo
echo "Renaming $i to:\c "
file=`basename $i .log`
echo "$file.bak"
mv $i $file.bak
done
----------------------------


Hope this helps!

Best Regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)