[comp.unix.xenix] Weird File Names

root@raider.MFEE.TN.US (Bob Reineri) (02/19/89)

I run a public access site, and have some users that are fairly new to the
Uni* world (myself included). It takes my users a while to get used to the 
environment, and often they press many wrong keystrokes before getting the
hang of things.

One of them has a file in his home directory that I can't get rid of to save
my life. In a regular 'l' listing, it has a filename of the greek letter
Sigma. Doing an l with the -b option reveals a value of '/744'. Anyone can
give me a way to delete this annoying little file ? Thanks.

rm refuses to recognize it, even if I just try to delete all files interactively. That is, 'rm -i *' skips over it. 

Bob
-- 
*RaiderNet Public Access, Murfreesboro, TN.  -  Middle Tenn's Unix GateWay*
*Phone: (615)896-8716/(615)896-7905 Mail: BOX 2371, Murfreesboro, TN 37133*
*DOMAIN: root@raider.MFEE.TN.US  UUCP:!{ames,rutgers,decwrl}!killer!raider*

jeff@swusrgrp.UUCP (Jeff Tye sys adm) (02/20/89)

In article <91@raider.MFEE.TN.US>, root@raider.MFEE.TN.US (Bob Reineri) writes:
> One of them has a file in his home directory that I can't get rid of to save
> my life. In a regular 'l' listing, it has a filename of the greek letter
> Sigma. Doing an l with the -b option reveals a value of '/744'. Anyone can
> give me a way to delete this annoying little file ? Thanks.
> 
> rm refuses to recognize it, even if I just try to delete all files interactively. That is, 'rm -i *' skips over it. 

Try this:

1)	In the directory where the file is type:

		ls -il *|more

2)	Note the number in the left column corresponding to the file
	that you want to remove. For example:

	242 -rw-------   1 jeff     group         29 Feb 19 21:47 junkfile

	(The number on the left is the inode number)

3)	Type this command (very carefully):

		find . -inum inode -exec rm {} \;   (return)

	(where inode is the number found in step 2)

		find . -inum 242 -exec rm {} \;

Voila'! It's gone.

-- 
Jeff Tye @ Copperstate Business Systems                   VOICE (602) 244-9391
ncar!noao!asuvax!hrc!swusrgrp!jeff         southwest!/usr/group (602) 275-2541

manes@marob.MASA.COM (Steve Manes) (02/20/89)

From article <91@raider.MFEE.TN.US>, by root@raider.MFEE.TN.US (Bob Reineri):
| One of them has a file in his home directory that I can't get rid of to save
| my life. In a regular 'l' listing, it has a filename of the greek letter
| Sigma. Doing an l with the -b option reveals a value of '/744'.
| rm refuses to recognize it, even if I just try to delete all files interactively. That is, 'rm -i *' skips over it. 

That won't work because '*' attempts to expand a directory into standard
filenames as an argument for 'rm'.  Try this:

1) get the inode number with 'ls -i'.

2) type 'find . -inum NNNNN -exec mv {} <newname>, or
        'find . -inum NNNNN -exec rm {}'


-- 
Steve Manes            Roxy Recorders, Inc.             Magpie-HQ BBS
UUCP : {rutgers|cmcl2}!hombre!magpie!manes              (212)420-0527
Smail: manes@MASA.COM

frankb@usource.UUCP (Frank Bicknell) (02/22/89)

In article <281@swusrgrp.UUCP>, jeff@swusrgrp.UUCP (Jeff Tye sys adm) writes:
> In article <91@raider.MFEE.TN.US>, root@raider.MFEE.TN.US (Bob Reineri) writes:
> > One of them has a file in his home directory that I can't
> > get rid of to save my life. In a regular 'l' listing, it has
> > a filename of the greek letter 

> Try this:
... find the inode # ...
> 3)	Type this command (very carefully):
> 
> 		find . -inum inode -exec rm {} \;   (return)
> 
> 	(where inode is the number found in step 2)

> Voila'! It's gone.

BE CAREFUL that there are no other filesystems below '.', however.
Although Bob said the file was in his home directory and
filesystems are rarely mounted below home directories, if you
generalize this solution to, say '/', you could wipe out as many
files as you have filesystems mounted!  (ie there could be an
inode #x on each of those filesystems).

Safer would be:

 		find . -inum inode -exec rm -i {} \;

or use a fix program which does this only to the file in the
current filesystem (where _is_ that source code?).
-- 
Frank Bicknell; 1405 Main St, Ste 709; Sarasota, FL 34236-5701
killer!usource!frankb

davidsen@steinmetz.ge.com (William E. Davidsen Jr) (02/22/89)

In article <91@raider.MFEE.TN.US> root@raider.MFEE.TN.US (Bob Reineri) writes:
| I run a public access site, and have some users that are fairly new to the
| Uni* world (myself included). It takes my users a while to get used to the 
| environment, and often they press many wrong keystrokes before getting the
| hang of things.

Will you settle for a utility that turns all of the crap names into
legible names? Thought you would. Also does control characters, high bit
set, embedded blanks, etc. Converts uppercase to lowercase because a lot
of DOS archivers and stuff generate it.

No fancy shar stuff, trim it by hand:
________________________________________________________________

/*  X X U  --  20-to-Unix filename converter  */

/*
 Change DEC-20 or VAX/VMS style filenames into normal Unix names.
 Handy for use after ftp MGETs, when you find your directory full of
 files with names like LIB:<KERMIT>CKUFIO.C.2 or FRED::[ETHEL]A.B;37
 when all you really wanted was ckufio.c and a.b.

 Usage: xxu file(s)

 Action: Renames argument files as follows:
   strips Unix path name from front (up to rightmost '/') if present
   strips DEC device:, node:: names from front (up to rightmost ':') if present
   strips DEC-20 <directory> or VMS [directory] name if present
   strips DEC-20 version number from end (everything after 2nd dot) if present
   strips VMS generation number from end (everything after ';') if present
   lowercases any uppercase letters
   honors DEC-20 CTRL-V quote for special characters
   discards unquoted unprintable characters
   if result is null, file is renamed to xxfile-n, where n is a number.
   if result would write over an existing file, file also renamed to xxfile-n.

 Recommended procedure: make a new directory, cd to it, then FTP files
 from DEC-20 or VMS system, then do "xxu *".

 Author:  F. da Cruz, CUCCA, July 85
*/

#include <stdio.h>
#if	SYSV | M_XENIX
#include <sys/types.h>
#endif
#include <ctype.h>
#include <sys/file.h>			/* For access() */
/* <<<<<<<< define NO_RENAME on cc line if missing >>>>>>>> */

char name[500];				/* File name buffer */
char *pp, *cp, *xp;			/* Character pointers */
char delim;				/* Directory Delimiter */
int dc = 0, n = 0;			/* Counters */
int quote = 0, indir = 0; done = 0;	/* Flags */

main(argc,argv) int argc; char **argv; {

    if (argc < 2) {			/* Give message if no args */
	fprintf(stderr,"Usage: xxu file(s)\n");
	exit(1);
    }
    n = 0;				/* Unfixable filename counter */
    while (--argc > 0) {		/* For all files on command line... */
	argv++;
	xp = *argv;			/* Copy pointer for simplicity */
	printf("%s ",*argv);		/* Echo name of this file */

	pp = name;			/* Point to translation buffer */
	*name = '\0';			/* Initialize buffer */
	dc = 0;				/* Filename dot counter */
	done = 0;			/* Flag for early completion */

	for (cp = xp; (*cp != '\0') && !done; cp++) { /* Loop thru chars... */

	    if (quote) {		/* If this char quoted, */
		*pp++ = *cp;		/*  include it literally. */
		quote = 0;
	    }
	    else if (indir) {		/* If in directory name, */
		if (*cp == delim) indir = 0; /* look for end delimiter. */
	    }
	    else switch (*cp) {
		case '<':		/* Discard DEC-20 directory name */
		    indir = 1;
		    delim = '>';
		    break;
		case '[':		/* Discard VMS directory name */
		    indir = 1;
		    delim = ']';
		    break;
		case '/':		/* Discard Unix path name */
		case ':':   	    	/*  or DEC dev: or node:: name */
		    pp = name; 
		    break;
		case '.':		/* DEC -20 generation number */
	    	    if (++dc == 1)	/* Keep first dot */
		    	*pp++ = *cp;
		    else		/* Discard everything starting */
		    	done = 1;	/* with second dot. */
		    break;
		case ';':		/* VMS generation or DEC-20 attrib */
		    done = 1;		/* Discard everything starting with */
		    break;		/* semicolon */
	    	case '\026':		/* Control-V quote for special chars */
		    quote = 1;		/* Set flag for next time. */
		    break;
		default:
		    if (isupper(*cp))  	/* Uppercase letter to lowercase */
	    	    	*pp++ = tolower(*cp);
		    else if (*cp == ' ')/* change blanks to underscore */
		        *pp++ = '_';
		    else if (isprint(*cp)) /* Other printable, just keep */
		    	*pp++ = *cp;
	    }
	}
	*pp = '\0';			/* Done with name, terminate it */
	if (strcmp(name,xp) == 0) {	/* If no renaming necessary, */
	    printf("(ok)\n");		/*  just give message. */
	    continue;
        }
	while (*name == '\0' || access(name,0) == 0) { /* Find unique name */
	    sprintf(name,"xxfile-%d",n++);
	}
	printf("=> %s ",name);		/* Tell what new name will be */
	if (rename(xp,name) == 0)	/* Try to rename it */
	    printf("(ok)\n");		/* Say what happened */
	else
	    perror("failed");
    }
    exit(0);				/* Done. */
}

/*****************************************************************
 |  rename - for systems lacking the rename system call
 |----------------------------------------------------------------
 |  Arguments:
 |   1) string - current filename
 |   2) string - new filename
 ****************************************************************/

#if	NO_RENAME
rename(oldname, newname)
    char *oldname, *newname;
{
    char cmdline[133];
    
    sprintf(cmdline, "mv \"%s\" %s", oldname, newname);
    return system(cmdline);
}
#endif
________________________________________________________________

That's all folks!
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

mmcg@bruce.oz (Mike Mc Gaughey) (02/22/89)

From article <281@swusrgrp.UUCP>, by jeff@swusrgrp.UUCP (Jeff Tye sys adm):
> In article <91@raider.MFEE.TN.US>, root@raider.MFEE.TN.US (Bob Reineri) writes
>> One of them has a file in his home directory that I can't get rid of to save
>> my life. In a regular 'l' listing, it has a filename of the greek letter
> Try this:
> 
> [info on using find with inode numbers deleted]

	Whatever happened to the simple 

		rm -ir .

	[or is xenix brain damaged?]

	Mike.

nick@aimed.UUCP (Nick Pemberton) (02/22/89)

In article <281@swusrgrp.UUCP>, jeff@swusrgrp.UUCP (Jeff Tye sys adm) writes:
> In article <91@raider.MFEE.TN.US>, root@raider.MFEE.TN.US (Bob Reineri) writes:

[stuff about trouble with weird filename, and how to remove it]

I had just the same problem in /usr/spool/uucp, and hadn't gotten round
to figuring it out. Jeff's suggestion did the trick.

Tx.

-- 

Nick Pemberton                   UUCP: !{utzoo,utai}!lsuc!aimed!nick
AIM, Inc                          Bus: (416) 429-4913
                                 Home: (416) 690-0647

daveh@marob.MASA.COM (Dave Hammond) (02/23/89)

>	Whatever happened to the simple 
>
>		rm -ir .
>

To quote George Carlin: ``Dat don't seem wise to me''  ...  [:-\]

--
Dave Hammond
daveh@marob.masa.com

det@hawkmoon.MN.ORG (Derek E. Terveer) (02/26/89)

In article <167@usource.UUCP>, frankb@usource.UUCP (Frank Bicknell) writes:
> Safer would be:
>
>  		find . -inum inode -exec rm -i {} \;
>
> or use a fix program which does this only to the file in the
> current filesystem (where _is_ that source code?).

The newer OS equivalents for this command that is restricted to a single fs
would be:

		/* bsd -- don't cross(X) over to another device(DEV)
		 */

		find . -xdev -inum inode -exec rm {} \;

		/* sysv -- stay on own mounted fs
		 */

		find . -mount -inum inode -exec rm {} \;

-- 
Derek Terveer 	    det@hawkmoon.MN.ORG || ..!uunet!rosevax!elric!hawkmoon!det
		    w(612)681-6986   h(612)688-0667

"A proper king is crowned" -- Thomas B. Costain

jpr@dasys1.UUCP (Jean-Pierre Radley) (02/27/89)

In article <91@raider.MFEE.TN.US> root@raider.MFEE.TN.US (Bob Reineri) writes:
>One of them has a file in his home directory that I can't get rid of to save
>my life. In a regular 'l' listing, it has a filename of the greek letter
>Sigma. Doing an l with the -b option reveals a value of '/744'. Anyone can
>give me a way to delete this annoying little file ? Thanks.
>
>rm refuses to recognize it, even if I just try to delete all files
>interactively. That is, 'rm -i *' skips over it. 

This question comes up every other month. When you start getting other
than plain printable ASCII characters in a file name, or if you get a file
name that starts with '-', you won't be able to enter a keyboard command
too readily that will work for 'rm'. The expansion of '*' may not,
depending on what version of which shell you're using, cover 8-bit
characters; in any case, it won't encompass filenames starting with '.'.

First, 'cd' to the directory-with-the-problem. Then type 'ls -i' to obtain
the inode number, say NNN, of the weird filename.
Then, use the '-inum' option of find (it seems to be present in all versions
of find, but SCO seems to have dropped any reference to -inum in the manual
page for find):

  find . -inum NNN -exec rm {} \;

Perhaps you first want to see if the file is of interest, and find that you
can't feed its name to 'cat' any more than you could feed it to 'rm'. Then:
  
  find . -inum NNN -exec mv {} newname \;
-- 
Jean-Pierre Radley		Honi soit		jpr@dasys1.UUCP
New York, New York		qui mal			...!hombre!jpradley!jpr
CIS: 76120,1341			y pense			...!hombre!trigere!jpr

frankb@usource.UUCP (Frank Bicknell) (03/01/89)

In article <828@hawkmoon.MN.ORG>, det@hawkmoon.MN.ORG (Derek E. Terveer) writes:
> The newer OS equivalents for this command that is restricted to a single fs
> would be:
> 
> 		/* bsd -- don't cross(X) over to another device(DEV)
> 		 */
> 
> 		find . -xdev -inum inode -exec rm {} \;
> 
> 		/* sysv -- stay on own mounted fs
> 		 */
> 
> 		find . -mount -inum inode -exec rm {} \;

That's nice when it gets here, but if you have xenix 2.3.1 it's
not here yet.  Thanx for the info, though!











-- 
Frank Bicknell; 1405 Main St, Ste 709; Sarasota, FL 34236-5701
killer!usource!frankb

edhew@egvideo.UUCP (Ed Hew) (03/04/89)

In article <718@bruce.oz> mmcg@bruce.oz (Mike  Mc Gaughey) writes:
>From article <281@swusrgrp.UUCP>, by jeff@swusrgrp.UUCP (Jeff Tye sys adm):
>> In article <91@raider.MFEE.TN.US>, root@raider.MFEE.TN.US (Bob Reineri) writes
>>> One of them has a file in his home directory that I can't get rid of to save
>>> my life. In a regular 'l' listing, it has a filename of the greek letter
>> Try this:
>> 
>> [info on using find with inode numbers deleted]
>
>	Whatever happened to the simple 
>
>		rm -ir .
>
>	[or is xenix brain damaged?]
>
>	Mike.

Actually, this works quite well in Xenix (at least the SCO flavour).
If you're not comfortable with using it interactively, and want to be
*really* safe (like when you have 2 or 3 files that _appear_ to be the
same, but really aren't, due to embeded unprintable char's), do the
following:

cd {required_dir}
ls > /tmp/junk
vi /tmp/junk		# to pare it down to the files you think
		 	# you want to remove.
rm -i < `cat /tmp/junk`

This makes you a bit more comfortable when you have to perform surgery
cd'd to /dev .....		--ed		{edhew@egvideo.uucp}

  Ed. A. Hew        Technical Marketing Director        Xeni/Con Corporation
  UUCP@bus: ..!{uunet!}utai!lsuc!xenicon!edhew  Internet: edhew@xenicon.uucp
  UUCP@res: ..!{uunet!}watmath!egvideo!edhew    Internet: edhew@egvideo.uucp
   #I haven't lost my mind, it's backed up on floppy around here somewhere!