Shell script to check files if exist else touch the file
Hi All,
Thanks in Advance
I wrote the following code
there are some 8 files in the directory
it has the common prefix "DUMP_" and suffix as ".csv"
so i used a for loop to check for matching the filenames
but i am getting error in touch command as
Creating
touch: missing file operand
Try `touch --help' for more information.
expr: syntax error
and also error in expr
and the extension .csv is not appending to the files
and its creating only DUMP_subscriber and other files without extension .csv
Kindly assist
Last edited by vbe; 08-30-2012 at 11:33 AM..
Reason: indent...
What is the expr for? If you want to loop around all those files you could use: for i in subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account
(without quotes)
$FILE = DUMP_subscriber.csv
then it will check in the directory if that file exist or not.
if not it will touch and create a file DUMP_subscriber.csv
in the code
FILE="SDP_DUMP_$i.csv"
for each counter it will create one file as in the 8
DUMP_accumulator.csv
DUMP_dedicatedaccount.csv
DUMP_faflistAcc.csv
DUMP_faflistSub.csv
DUMP_mapping.csv
DUMP_promplan.csv
DUMP_subscriber.csv
DUMP_pam_account.csv
and will check all the eight files
if its not exist it will create the file
Hello,
I needed help with a shell script where in it checks if a file exists under a directory and also checks the age of the file and delete it if it is older than 3 weeks.
thanks (10 Replies)
our requirement is that we need to create a touch file on 2 4 and 7 th working day of the each month ...
If the days falls on saturday/sunday, the touch file should be created on next working day.
We are currently on Red hat 6.5 (1 Reply)
Hi,
I've a situation where i need to check for the file existence and create a zero byte file based on the parameter,in some cases i need to touch and in some case i dont need to touch with zero byte file please help me on parameterizing this touch command??
Regards.
San (2 Replies)
Hi,
I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is
# echo $0
-sh
My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Hi,
Another problem, here is my code
#!/bin/sh
dir='/opt/apps/script/CSV'
datadir='/opt/apps/script/data'
while : ; do
ls -1rt $dir/*.csv > /dev/null 2>&1
if ;then
cp $datadir/weekly.txt $dir/weekly.csv
else
exit 0
fi
done (10 Replies)
UNIX Shell Script
I'm in /home/suneel dirctory
in that directory need to check for a path for example com/src/resources
If Path exists need to copy the files from one directory
If path not exist need to create the folders and copy the files
UNIX shell script help required (3 Replies)
I need a script that will check for the existence of new files that FTP'd in the morning, results go to log file. The 2nd step is to compare the new file with the previous days file. If the new file size is 30% or more smaller in size then previous day this needs to also be sent to log.
This... (1 Reply)
Hi,
I would like to perform bash which would check the file A.txt to be size 0 or not. If the size is 0, I would copy file B.txt to replace A.txt.
Please help.
Thanks.
-Jason (6 Replies)
I have a shell script that runs all the time looking for a certain type of file and then it processes the file through a series of other scripts. The script is watching a directory that has files uploaded to it via SFTP. It already checks the size of the file to make sure that it is not still... (3 Replies)