Hi,
you tried something? Or should us write the script for you?
I assure you it is very simple, and think if you try you can manage it.
There's no help if we write the script for you, because you won't learn anything.
Try to write the script and then ask the forum for help if it doesn't work .
Hi,
bash tells you "command not found" because you typed [-f ... without spaces,
anyway the option "-f" check a single file so even if you write the if statement the right way, the code you posted won't work.
Anyway if you want to delete files you can try this:
if you want to send the directory as a parameter of the script, you can try what follow
./script_to_delete_files.sh <directory>
in your code you'll write:
[[ -z "$1" ]] && echo "you must enter a dir" && exit 0
[[ ! -d "$1" ]] && echo "Directory $1 doesn't exist" && exit 0
for FILES in $(cat <filestodelete>); do
rm /path_before_your_directory/$1/$FILES
done
Hope it helps
Bye
Last edited by Yogesh Sawant; 04-13-2009 at 07:32 AM..
Reason: added code tags
Hi.
My example:
I have a filesystem /log. Everyday, log files are copied to /log. I'd like to set owner and permission for files and directories in /log like that
chown -R log_adm /log/*
chmod -R 544 /log/*It's OK, but just at that time. When a new log file or new directory is created in /log,... (8 Replies)
Hi
My directory structure is as below.
dir1, dir2, dir3
I have the list of files to be deleted in the below path as below.
/staging/retain_for_2years/Cleanup/log $ ls -lrt
total 0
drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2
drwxr-xr-x 2 root ... (2 Replies)
he following are the files available in my directory
RSK_123_20141113_031500.txt
RSK_123_20141113_081500.txt
RSK_126_20141113_041500.txt
RSK_126_20141113_081800.txt
RSK_128_20141113_091600.txt
Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Hi,
I am looking for a shell script which serves the below purpose.
Please find below the algorithm for the same and any help on this would be highly appreciated.
1)set of strings need to be replaced among set of files(directory may contain different types of files)
2)It should search for... (10 Replies)
Hi all,
I need a script to delete a large set of files from a directory under / based on an input file and want to redirect errors into separate file.
I have already prepared a list of files in the input file.
Kndly help me.
Thanks,
Prash (36 Replies)
Hello,
I have several files in a specific directory.
A specific string in one file can occur in another files.
If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string.
Example.
file1
ShortName "Blue... (2 Replies)
hi
How can one change an environment varaible inside a shell script
say my bash shell has a env variable export FOO="Day"
no i want to write a script inside which the FOO variable is modified to say
export FOO=NIGHT
after this script finishes te bash shell should show me NIGHT when i... (1 Reply)
Hi All,
I have a report which I am running from unix shell script using CONCSUB utility.
Just for testing I put the order number in shell script as ord_low and ord_high.
But Actually what is going to happen is that the order numbers will be in a file say a.txt
and this CONCSUB should... (0 Replies)