Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!van-bc!ubc-cs!mprgate.mpr.ca!henderso From: henderso@mpr.ca (Mark Henderson) Newsgroups: comp.unix.wizards Subject: Re: Removing erroneous directory entries: help needed Message-ID: <1991May12.175355.27106@mprgate.mpr.ca> Date: 12 May 91 17:53:55 GMT References: <1991May9.022627.8139@gpu.utcs.utoronto.ca> Sender: news@mprgate.mpr.ca Distribution: na Organization: MPR Teltech Ltd., Burnaby, B.C., Canada Lines: 81 In article <1991May9.022627.8139@gpu.utcs.utoronto.ca> aponty@gpu.utcs.utoronto.ca (Adele Ponty) writes: >One of the users on our system managed to create an entry >in one of our user_data directories that appears at the top >of the directory listing as, -k@ . A long listing reveals >it to be some sort of link they attempted to create; >l--------- -k@ ... ... -k@ -> df >I don't know how they managed this but can someone tell me how >to get rid of it? I have a feeling that I may see more of these. >Thanks. >-- > ==== ==M= > INTERNET: aponty@gpu.utcs.utoronto.ca ==== ==i= > UUCP: wheaties@intacc.uucp (bbs) ==== ==n= > aponty@agora.rain.com (alternate) =======g= Use ls -i to find out the inode number of the file/link and then either use find . -inum xxxx -exec rm '{}' \; or the following short program to delete the file. /* * remove a file at a given inode number in the current directory usage: rm * useful for getting rid of files with strange names. Safer * than clri and can be run without being root. * Very simple-minded, but useful. * Usage: * irm * The inode number can be obtained by using ls -i * So to get rid of file *****.???'\^C^D^Z * cd into the directory containing the file. * Do an ls -i and find the inode number of the file * (say 30240) then type * irm 30240 * * Mark Henderson - Tektronix, Inc. * * BSD43 is for VAX BSD 4.3 (do not use BSD43 for SUN OS 4.0+) Tested under SUN * OS 4.0 and VAX BSD 4.3. Is BSD43 is not specified compiles for SUN OS 4.0/4.1 */ #include #include #ifdef BSD43 #include #else #include #endif main(argc, argv) int argc; char *argv[]; { ino_t target; DIR *dirp; #ifdef BSD43 struct direct *dp; #else struct dirent *dp; #endif if (argc != 2) { printf("\nusage irm \n"); exit(1); } target = atol(argv[1]); dirp = opendir("."); for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { /* printf("%s %ld\n",dp->d_name, dp->d_fileno); */ if ((dp->d_fileno) == target) { printf("\nFOUND: %s\n", dp->d_name); closedir(dirp); if (!unlink(dp->d_name)) printf(" deleted\n"); else printf(" delete failed\n"); exit(0); } } printf("\nNOT FOUND\n"); closedir(dirp); }