Michael C. Toren on 1 Feb 2006 17:28:39 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Interactive rm


Art Alexion wrote:
> > How can I restore rm's default behavior so that "rm *" requires
> > confirmation, but "rm specified_file" does not?

gyoza@comcast.net wrote:
> Create an alias.

morgan wrote:
> If you're using bash you would create an alias:
> 
> alias rm="rm -i"

Creating an alias won't solve Art's problem, which is using the "-i" flag
when rm is passed multiple files, but not using "-i" when only a single
file is specified -- rather, an alias will use "-i" in every case.  One
possible solution is to create a bash function which determines how many
arguments it was passed:

	rm()
	{
	    if [ $# -lt 2 ]
	    then /bin/rm $*
	    else /bin/rm -i $*
	    fi
	}

This works for the majority of cases:

	[mct@ellesmere ~]$ touch foo bar baz
	[mct@ellesmere ~]$ rm foo
	[mct@ellesmere ~]$ rm bar baz
	/bin/rm: remove `bar'? y
	/bin/rm: remove `baz'? y

HTH,
-mct
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug