rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* smart rm fn...
@ 1992-02-12 14:19 Tore Morkemo
  0 siblings, 0 replies; 2+ messages in thread
From: Tore Morkemo @ 1992-02-12 14:19 UTC (permalink / raw)
  To: rc list


-- Hei !

   I just got the idea of writing a smart rm function but I havent got
   too much exeperience in writing rc scripts, maybe one of you rc-gurus
   could take this as an exercise.

   I don't like the idea of fn'ing rm to move the file to /tmp or
   somewhere else ( fn rm {mv $* /tmp} ) since this tend to fill up
   /tmp. But I have to admit that I just removed a file that I shouldn't
   have removed....:-(   So what about this idea:

   Make a fn that REMOVES only the files that I never need, like .o files,
   and MOVES all the files that ends with .c .h etc. to /tmp.
   The file extensions that I would like to move should be put in a
   list like :

     move_file_extensions=(.c .h .1 .C .cpp)


PS:
   Actually I just came up with a better solution to the entire problem,
   but I still think it's a good rc exercise and I would like to see
   a good solution.....


Tore.

+----------------------------------------------------------------------+
!   Tore Morkemo, Bibliotek-Systemer A/S, N-3250 Larvik, Norway        !
!   uucp: ...!bibsyst.no!tore        Tel: +47 34 82 202                !
!            tore@bibsyst.no         Fax: +47 34 85 185                !
+----------------------------------------------------------------------+


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: smart rm fn...
@ 1992-02-12 17:34 Byron Rakitzis
  0 siblings, 0 replies; 2+ messages in thread
From: Byron Rakitzis @ 1992-02-12 17:34 UTC (permalink / raw)
  To: rc, tore

This is just off the top of my head, but the problem is exactly suited
for the ~ operator:

	fn rm {
		for (i) {
			if (~ $i *^$move_file_extensions) {
				mv $i /tmp/save_dir
			} else {
				builtin rm $i
			}
		}
	}

There, how's that? (you'll want to add options etc. but I haven't got
time right now)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1992-02-12 17:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-02-12 14:19 smart rm fn Tore Morkemo
1992-02-12 17:34 Byron Rakitzis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).