Deleting a "weird" file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deleting a "weird" file
# 1  
Old 06-04-2009
Deleting a "weird" file

Hey guys,
A little problem that I'm facing. I unintentionally copied something to a directory and now i want to clean it up. Please help in this regard ...

Here is the list of the files that I have (ls -la):


-r--r----- 1 ovq123 Khan 16777216 J
-rw-rw-r-- 1 ovq123 Khan 2760 Feb 7 2008 core.war
-rw-r--r-- 1 ovq123 Khan 17194526 May 22 11:25 MLWM.war

The bolded out line is the one that I'm having problem with. I don't know what that files name is .... It appears as just blank. The month is just J. Can I specifically delete this file on the base of the file size and the user (or anything) ??

Gurus, Please help a brother out!! appreciate it very much.

Thanks....

Mister Khan
# 2  
Old 06-04-2009
The filename probably contains control characters. First find out what characters are in the filename and how many there are:

Code:
ls -la | sed -n l

Also try the "-b" switch to "ls".

Code:
ls -lab


Between these two outputs from "ls" there should be enough information to rename the file. I would not recommend trying to delete the file with its current name.
# 3  
Old 06-04-2009
This is what I got ...

$ ls -lab | grep $LOGNAME

-r--r----- 1 ovq123 Khan 16777216 Jul 9 2008 \177\177\177\177\177\177\177\177\177\177\177\177

-rw-rw-r-- 1 ovq123 Khan 2760 Feb 7 2008 coreUtils.war

-rw-r--r-- 1 ovq123 Khan 17194526 May 22 11:25 QueuesML.war

I tried re-naming it (mv command) but it wouldn't let me ... any other ideas ??
# 4  
Old 06-04-2009
ls -i will tell you the inode number of the tile, which you can feed into the find tool to help you delete or rename it. Here's an example.
Code:
# Create an example file
$ touch this
# Get its inode
$ ls -i
66278 this
# Find and rename the file based on its inode
$ find ./ -inum 66278 -exec mv '{}' 'sanity' ';'
$ ls -i
66278 sanity
$ rm sanity
$

# 5  
Old 06-04-2009
Does it show any error, message, or something after you try to delete it?
Also, how are you trying to delete the file?
# 6  
Old 06-04-2009
Thanks a lot methyl and corona ... it worked like wonders. Wow, I feel so good. I was trying to delete this bugger for the last 3 days. Finally ... done. Thanks again.

Regards,
Mister Khan
# 7  
Old 06-05-2009
Just for completeness we can use the output from "ls -lab" to generate the filename. Here I am creating a file with the same name as yours and renaming the file.

Code:
#!/bin/ksh
FILENAME=`echo "\0177\0177\0177\0177\0177\0177\0177\0177\0177\0177\0177\0177"`
touch "${FILENAME}"
ls -labd "${FILENAME}"
mv "${FILENAME}" junk_file
ls -labd junk_file


-rw-r--r--   1 root       sys              0 Jun  5 14:38 \177\177\177\177\177\1
77\177\177\177\177\177\177
-rw-r--r--   1 root       sys              0 Jun  5 14:38 junk_file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Commenting out "expr" creates weird behavior

This really puzzles me. The following code gives me the error 'expr: syntax error' when I try to do multi-line comment using here document <<EOF echo "Sum is: `expr $1 + $2`" EOF Even if I explicitly comment out the line containing the expr using "#", the error message would still exist... (3 Replies)
Discussion started by: royalibrahim
3 Replies

4. Shell Programming and Scripting

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line... (4 Replies)
Discussion started by: sudeep.id
4 Replies

5. UNIX for Dummies Questions & Answers

Deleting "user input line number" from a file using sed

Hi I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this Enter the line to... (1 Reply)
Discussion started by: sudeep.id
1 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Dummies Questions & Answers

Script For Deleting Contents of "Live" Log File

In our shop, we have a situation where a log file from our interface engine software has begun maxing out in file size (reaching the 32-bit "2147483647" limit). Currently, the only way to rectify this is to stop the interface and restart it, which generates a new log. Easy enough, but the... (6 Replies)
Discussion started by: rjhjr64
6 Replies

8. UNIX for Dummies Questions & Answers

weird password popup on "admin" mentions

I had a site that sold stock photography and some guys I know set up a shopping cart and gallery system for it. One thing they did was give me an admin page (mysite.net/admin) where I could upload new images and change prices and all that. For that admin page they set a password popup prompt. I... (4 Replies)
Discussion started by: lex0062
4 Replies

9. OS X (Apple)

Weird "security" bahavior with SSL certificates

Hello, I have been attempting to automate the addition of SSL certificates to keychains on a MAC using the "security" command. I've noticed two things, 1 of which I don't understand. 1. If I use something like "security add-trusted-cert -d -k /System/Library/Keychains/SystemRootCertificates... (1 Reply)
Discussion started by: prafulnama
1 Replies

10. Shell Programming and Scripting

Weird problem with output from "date '+3600*%H+60*%M+%S' "

Hi, I came across a script a few months ago that allowed you to use the following script to include the current time into your prompt (useful from auditting purposes): # Set Prompt typeset -RZ2 _x1 _x2 _x3 let SECONDS=$(date '+3600*%H+60*%M+%S')... (5 Replies)
Discussion started by: m223464
5 Replies
Login or Register to Ask a Question