I am searching for some files (*.sem and *.chk and *.temp) in morethan one directories.
if i found .sem and .chk files(base name should be same) i am deleting these 2 files because i need to delete .chk files if i found respective .sem file
i am also deleting other .sem files only even if i dont find respective .chk file as i should remove all .sem files
i am also check for .temp files and deleting them all of as well. Here is the example:
I have following files in different directories (this is the output of find command)
in the above case
i should straight a way delete 3.sem and 3.chk as base name is same and .sem and .chk files present
1.temp and 2.temp can be deleted as i am deleting all the .temp files.
2.sem can also be deleted as i am deleting all other sem files
So Now, the output should be
for that i am using below script, but the controller is not going inside the if loop, am i doing any mistake here? can somebody help me?
in the above code i just mentioned echo instead of rm for testing purpose.
Thanks for your help,
Vasu
Moderator's Comments:
Please use CODE tags for sample input and sample output as well as for sample code segments.
Last edited by Don Cragun; 10-05-2015 at 08:21 PM..
Reason: Add CODE tags.
There is some relatively slow and inefficient code in your script assuming you are using a shell with standard variable expansion capabilities. What operating system and shell are you using?
With a POSIX conforming shell, you might want to try something like:
and take out the echo if it looks like that is doing what you want.
Last edited by Don Cragun; 10-05-2015 at 09:49 PM..
Reason: Add sample code.
This User Gave Thanks to Don Cragun For This Post:
Paraphrasing your spec in post#1: delete all .temp and all .sem files unconditionally, and delete .chk files if the respective .sem exists.
Don Cragun's proposal above gets close but would delete .chk if a .temp exists. Try in lieu:
---------- Post updated at 14:20 ---------- Previous update was at 14:17 ----------
I am sorry for troubling again, there is some confusion in requirement. here is the actual requirement and what i have implemented.
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
Hello,
I am using Red Hat 2.6.23.1 with RAID 6 controller (card).
(When I use "cat /proc/partitions" I do not see the separate HDDs in the RAID, I see one drive for the RAID itself, as it is considered 1 large drive.)
I used a "dd" check to test my RAID drive speed and found it was a bit slow,... (7 Replies)
Hi,
I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
Dear Solarizer,
If i have a disk let say like this c1t0d0s0
How to change the controller to be come example : c3t0d0s0
Thanxs For your replay
Regads,
tpx (3 Replies)
Hello all,
How does the Solaris identifies the controller subscript ? ( like c0txdxs0 or c1txdxsx ?? )
I have a unix box ( Ultra 30) running with 2.5.1.
When I connected an external hard disk to the on-board scsi port, it got identified as c0t1dxsx...
(... (1 Reply)