Changing the functionality of rm command

Changing the functionality of rm command

Post by Sumit Chawl » Wed, 24 Aug 2005 02:46:09



Hi All
 I am required to add some additional functionality to rm command. For
examople displaying the space being freed on deletion of the file. For
that I dont want to make any changes to the existing rm command. But I
need to define some utility with same name as rm. Such that my utility
shpould be called whenevr the user issues the rm utitlity. How to do
that ? Please guide.

Regards

Sumit Chawla("eNetra")
Slogan: "Hail the Invention"

 
 
 

Changing the functionality of rm command

Post by Jan Schamper » Wed, 24 Aug 2005 02:52:02


On 22 Aug 2005 10:46:09 -0700


> need to define some utility with same name as rm. Such that my utility
> shpould be called whenevr the user issues the rm utitlity. How to do
> that ? Please guide.

Mh,
- rename the original rm and write a shellscript
- put a shellscript 'rm' into a path that is searched prior to the
original rm's path
- aliases
- functions

Well, your choice

J.

--
"Be liberal in what you accept, and conservative in what you send."
- J. B. Postel, master of the net.

 
 
 

Changing the functionality of rm command

Post by Chris F.A. Johnso » Wed, 24 Aug 2005 04:08:12



Quote:> Hi All
>  I am required to add some additional functionality to rm command. For
> examople displaying the space being freed on deletion of the file. For
> that I dont want to make any changes to the existing rm command. But I
> need to define some utility with same name as rm. Such that my utility
> shpould be called whenevr the user issues the rm utitlity. How to do
> that ? Please guide.

    Please don't multi-post. Your question has been answered in
    another newsgroup.

    The best advice is: don't; use a different name. Changing the
    behaviour of rm is likeley to break existing scripts.

--
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>

 
 
 

Changing the functionality of rm command

Post by cLIeNUX us » Wed, 24 Aug 2005 13:27:27




>> Hi All
>>  I am required to add some additional functionality to rm command. For
>> examople displaying the space being freed on deletion of the file. For
>> that I dont want to make any changes to the existing rm command. But I
>> need to define some utility with same name as rm. Such that my utility
>> shpould be called whenevr the user issues the rm utitlity. How to do
>> that ? Please guide.

>    Please don't multi-post. Your question has been answered in
>    another newsgroup.

>    The best advice is: don't; use a different name. Changing the
>    behaviour of rm is likeley to break existing scripts.

>--
>    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
>    ==================================================================
>    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
>    <http://www.torfree.net/~chris/books/cfaj/ssr.html>

cLIeNUX rm won't  rm -rf /  

If you have that in a script, be glad I broke it ;o)

 
 
 

Changing the functionality of rm command

Post by Chris F.A. Johnso » Wed, 24 Aug 2005 18:06:28





>>> Hi All
>>>  I am required to add some additional functionality to rm command. For
>>> examople displaying the space being freed on deletion of the file. For
>>> that I dont want to make any changes to the existing rm command. But I
>>> need to define some utility with same name as rm. Such that my utility
>>> shpould be called whenevr the user issues the rm utitlity. How to do
>>> that ? Please guide.

>>    Please don't multi-post. Your question has been answered in
>>    another newsgroup.

>>    The best advice is: don't; use a different name. Changing the
>>    behaviour of rm is likeley to break existing scripts.

> cLIeNUX rm won't  rm -rf /  

   I believe the latest POSIX specs require rm to consider that
   command an error.

Quote:> If you have that in a script, be glad I broke it ;o)

   And what happens if you have that in a script and run it on a
   different machine, where there is no such protection?

   It's much safer to learn how to code correctly and safely.

--
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>

 
 
 

Changing the functionality of rm command

Post by hymi » Wed, 24 Aug 2005 23:00:07


In our last episode, the evil Dr. Lacto had captured our hero,

Quote:>Hi All
> I am required to add some additional functionality to rm command. For
>examople displaying the space being freed on deletion of the file.

I realize that this wasn't the point of your question, but there is no
guarantee that rm'ing a file will free any space.


===============================================================================

 
 
 

Changing the functionality of rm command

Post by nasi » Thu, 25 Aug 2005 03:06:38



>  I am required to add some additional functionality to rm command. For
> examople displaying the space being freed on deletion of the file. For
> that I dont want to make any changes to the existing rm command. But I
> need to define some utility with same name as rm. Such that my utility
> shpould be called whenevr the user issues the rm utitlity. How to do
> that ? Please guide.

Better use "alias" instead of removing the rm binary.

One method i could think of calculating the space is that you calculate
the sum of the files' space being used before deletion. Something like:
ls -l <myfiles>.<whatever> | awk '{sum = sum+$5} END {print sum}'. Then
use the rm command. Another way is to Available column of df command,
but that is not very reliable in many respects.

Nasir

 
 
 

1. Replacement for rm command to provide Recycle Bin functionality?

Hi
Does anyone know of a replacement for the rm command that would provide
functionality
similar to the Recycle Bin in Windows? That is, a command that would
move a file to a
Recycle Bin directory even though it was deleted so it could be quickly
recovered later
if needed?

Any suggestions, tips are welcome.

Dennis

2. 2940 Extended Translation?

3. rm command needs rm -r on RedHat

4. Networkproblem!

5. change rm command

6. Audit analycing on solaris 2.5

7. need to pipe a find or locate command into the rm command....PLEASE help!

8. Linux vs. XBox

9. kdm changed appearance/functionality after KDE 2.2 upgarde

10. Help to change the Esc-Esc pattern matching functionality

11. How to change mouse functionality under gnome?