Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to remove this file from command line?

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
#ls -la|head -2
total 2607
-rw------- 1 root system 428 May 14 12:38
#ls -lb|head -2
total 2472
-rw------- 1 root system 428 May 14 12:38 \015\015\015\015\015\015\015\015\015\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\032\032\032\004\004\004
 
try in ksh session

ls -lb "^L*^D"

Note: type these ^L and ^D as ctrl-V, followed by ctrl-L and ctrl-V followed by ctrl-D.
if you see the same weird filename (and only that one) appear as before, then use the command

rm -i "^L*^D"

to interactively remove the file; rm -i will prompt with

rm: Remove

(number of nonprintable chars) ?

just type y and enter to remove the file



HTH,

p5wizard
 
Is this the first file in a directory listing as seems to be indicated above?

Have you tried ls |head -1 | xargs -I {} mv () newname

Then rm newname
 
Hi,

Do an ls -i to get the i-node of the file
Do a find command with the previous i-node
example : to delete file zz.lis in my tmp directory usin i-node (first column in ls -il ):

Code:
ls -il /tmp/z*
   52 -rw-r--r--   1 root     system        10240 28 avr 14:03 /tmp/zz.cpio
   12 -rw-r--r--   1 root     system           97 28 avr 14:03 /tmp/zz.lis 

find /tmp -i 12 -exec rm {} \;
 
The think the interactive method suggested by p5wizzard (rm -i *) is easiest .... works well for me.
 
I like to set an array.

#set -A files $(ls /filesystem)
#print ${files[@]}

find the index of the file you want to remove. count begins at 0.

Then:
#rm ${files[7]} #if the file you want is the eigth file in the list.
 
If you had a number of these, you could do an ls > remove.lst on the directory - then vi edit out the entries that you want to leave - so the file remove.lst would have only the files that you want to remove. Then:

find `cat remove.lst` -print|whiler read name; do rm -ir $name;done
 
do rm -rfi (interactive) say yes to what you want to delete
 
rm -rfi?
I was on a system once (think it was HP-UX) where the "f" over-rode the "i". So, this just became a recursive remove everything command.

I'm probably just being paranoid.
 
you are correct my fault:
To delete a directory tree, enter:

rm -ir "start point"
for just files rm -i "file " or "*" (all files
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top