"Standard" Unix utilities

Jason Stephenson jason at sigio.com
Wed Feb 22 20:06:02 EST 2006


Tom Buskey wrote:

> Solaris has rename(2) also.

Just in case someone is reading this and doesn't know the man pages, 
rename(2) is a system call and part of the C standard library:


RENAME(2)                 FreeBSD System Calls Manual 
RENAME(2)

NAME
      rename -- change the name of a file

LIBRARY
      Standard C Library (libc, -lc)

SYNOPSIS
      #include <stdio.h>

      int
      rename(const char *from, const char *to);

DESCRIPTION
      The rename() system call causes the link named from to be renamed 
as to.
      If to exists, it is first removed.  Both from and to must be of 
the same
      type (that is, both directories or both non-directories), and must 
reside
      on the same file system.

      The rename() system call guarantees that if to already exists, an
      instance of to will always exist, even if the system should crash 
in the
      middle of the operation.
b



As Paul and others have pointed out, rename as a command appears to be 
part of Perl. Apparently, it isn't installed on FreeBSD when Perl 5.8.7 
is installed from ports with the standard options. I seem to recall 
seeing it long ago and far away, probably after installing Perl from 
source on a Solaris machine 5 years ago or so.

Anyway, I, too, have written a few utilities over the years. I wrote my 
own EOL converter that could handle \r, \n, and \r\n. It was smart 
enough to figure out what to do so long as you told it what to output. 
Now, I find "perl -pi -e 's/\r//' filename" works just about as well for 
what I usually needed the other one for.

Generally, I write a program for anything that I have to do more than 
once, particularly if it involves a lot of complicated steps.

Cheers,
Jason



More information about the gnhlug-discuss mailing list