I have some files like file, file.chk, file.sem and file.temp in huge. I would like to delete some files based on following criteria.
1. Unconditionally delete .sem and .temp files
2. If we found the actual file, don't remove .chk file, otherwise remove .chk file as well
for example I have:
I should straight a way delete following files:
Should NOT delete following files.
for this I have write the script as following:
But no luck, its not deleting .chk files. Could you please help me to fix if there is any issue in my above code?
Thanks in advance, appreciate your patience.
Vasu
Last edited by VasuKukkapalli; 10-29-2015 at 03:10 PM..
If we found the actual file, don't remove .chk file, otherwise remove .chk file as well
What is the actual file in the above quote that determines whether or not the .chk file is supposed to be removed.
With files with names like:
it looks like your current code will remove base.sem and base.temp unconditionally, and will remove base.chk if and only if base.sem existed and base does not exist.
If you want to remove base.chk if an only if base does not exist (in addition to removing base.sem and base.chk), try something more like:
NOTE: -o added before -name '*.chk' as suggested by MadeInGermany in post #5 in this thread.
Last edited by Don Cragun; 10-29-2015 at 05:17 PM..
Reason: Add missing -o.
These 2 Users Gave Thanks to Don Cragun For This Post:
Hello All,
Since i'm relatively new in shell script need your guidance.
I'm copying files manually based on a specific word in a file name and its extension and then moving it into some destination folder.
so if filename contains hyr word and it has .md and .db extension; it will move to TUM/HYR... (13 Replies)
Dear All,
It would be really nice, if you could help me to write a script for deletion of list of user( more than 15000 users) stored in a file and sorted by email address( i need deletion of only a particular type of mail address).
Is the any script to write and take the file as input and... (3 Replies)
Hi All,
I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing.
1.I need to display the .done files from the directory.
2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory
... (2 Replies)
In shell scripting, I can create a conditional statement based on the success or failure (exit status)of a command such as:
pinger()
{
ping -c 2 $remote_host >/dev/null 2>&1
ping_stat=$?
}
pinger
if ]; then
echo "blahblahblah"
exit 0
fi
how is this done using Python using... (3 Replies)
I need to read the contents of a file. Then I need to grep for a keyword and replace part of the grepped line based on the condition of previous and present line.
Example input file:
V {
port1 = P;
port2 = 0;
shift_port = P0; /* if next shift_port is P0 I need... (9 Replies)
I have posted this before but did not get many replies, so here it goes again.
I have several files name like this
If the file extension is 1a, I woould like to add at the beggining of the file the following sequence
If the file extension is 1b, thn the entry that should be added is the next... (2 Replies)
I want to be able to access an environment variable to control how a program is compiled.
So:
export MY_VERSN=9
Then ideally, within my C++ code, I would have
#if MY_VERSN = 9
iret = FRED9()
#else
iret = FRED()
#endif
The way I thought I could do it is that in the script that... (2 Replies)
i am a newbie and learning the ropes.........want to know how can i include a piece of code in a script (which redirects log files to a company standard out file) to delete the log files which are empty but should retain only those which has some process information in it......this should happen... (3 Replies)
Hi,
I have a list of directories which contain old files that are to be deleted.
I put the list of all directories in a txt file and it is being read by a script
Iam searching for the files older than 60 days using mtime and then deleting it
But all the files are getting deleted... (3 Replies)
Hi Experts,
I am working in HP-UX 11.0 workstaion.
How can i make a file to be executed with the corresponding software to be invoked or executed.
as in Windows.
ie., if a file index.html has to be double clicked to invoke the Netscape Navigator.
What i have to do to achieve this... (2 Replies)