Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


File extension search and copy


Login or Register to Reply

 
Thread Tools Search this Thread
# 15  
I've just noticed that a pair of back-quotes are missing around the date-command in the first line. It should be:

eval "`date '+MM=%m'`"

Sorry!
# 16  
where do you think i should add this part of code. should i run this external to the below code. Please let me know?

##!/usr/bin/sh -x

INPUT_DIR=/home/sadeep; export INPUT_DIR
OUTPUT_DIR=/usr/local/filefind/output; export OUTPUT_DIR
ERROR_DIR=/usr/local/filefind/error; export ERROR_DIR
LOG_DIR=/usr/local/filefind/log; export LOG_DIR



cd $INPUT_DIR

find $INPUT_DIR -name "*.[ct][sx][vt]"

if [ "$?" -ne 0 ]

then

echo "No csv or txt files found in pwd" > $LOG_DIR/filetransfer.log



exit 1

else

find $INPUT_DIR -name "*.[ct][sx][vt]" > filelist

cat filelist >> $LOG_DIR/filetransfer.log

fi



mkdir $OUTPUT_DIR/`date '+%m%d%y%`

for nccfile $INPUT_DIR/*

do

echo "---------------- Moving files to output folder ---------------" >> $LOG_DIR/filetransfer.log
echo " " >> $LOG_DIR/filetransfer.log
echo " " >> $LOG_DIR/filetransfer.log



#read

mv $nccfile $OUTPUT_DIR/`date '+%m%d%y%`

if [ "$?" -ne 0 ]

then
echo $nccfile " - Move Failed......." >> $LOG_DIR/filetransfer.log
echo " " >> $LOG_DIR/filetransfer.log
echo " " >> $LOG_DIR/filetransfer.log
else
echo $nccfile " - Moved Successfully to $OUTPUT_DIR" >> $LOG_DIR/filetransfer.log
echo " " >> $LOG_DIR/filetransfer.log
echo " " >> $LOG_DIR/filetransfer.log



fi

done

exit 0
# 19  
cron

Hi Bsandeep,

Put this entry in cron:

50 23 1-7 * * test `date +\%a` != Wed || /usr/sandeep/TestAutomate.sh
# 20  
Or rather just schedule it to run on Wednesdays by putting a 3 in the fifth column as:
Code:
50 23 * * 3 /usr/sandeep/TestAutomate.sh

# 21  
Also, per System Shock's clever solution, you can replace my suggested code:
Code:
eval "date '+MM=%m'"
[ -f $HOME/TestAutomate.M$MM ] && exit
rm -f $HOME/TestAutomate.M??; touch $HOME/TestAutomate.M$MM

with his:
Code:
[ `date '+%e' -ge 7 ] && exit

for exiting on all other Wednesdays (except the first one) in each monthSmilie
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
sed help - search/copy from one file and search/paste to another
ncwxpanther
I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ...... Shell Programming and Scripting
5
Shell Programming and Scripting
search for a file extension
divak
hi all, i'm new to shell scripting, i need help from u guys to do my task now.. i just need to check a file extension existence in a directory, and if it exists then i have to continue my processing. pls give me the command to check the extension of the files... Shell Programming and Scripting
6
Shell Programming and Scripting
Recursicely search and rename file extension
riverside
Greetings to all!!:b: I have one root folder containing several other folders inside it. This tree structure is deep. And the files are of similar extension. I need to start at the top level and recursively search and rename all the files with say .a extension to .b . This is the code to...... Shell Programming and Scripting
7
Shell Programming and Scripting
Search for all the unique file extension
riverside
Greetings to All ... :b: I have one root folder containing different other folders within it. I need to get the list of all different types of file extensions residing in those folders. Could anyone help me providing some shell script?... Shell Programming and Scripting
1
Shell Programming and Scripting
string search in folders with particular multiple file extension
anikanch
Hi, I am newbie in UNIX so please excuse for my questions. Is there a a way to search for string in files within folder and sub folder in particluar file extensions. Ex. search for ABC in folder 'A'(including it's sub folders) in html, xml files. Thanks, Ani... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers

Featured Tech Videos