LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2013, 04:22 AM   #1
bison72
LQ Newbie
 
Registered: May 2012
Posts: 8

Rep: Reputation: Disabled
remove filename started with "?" character


Hi there,

How do you remove a filename with "?" character? Thanks!

Louis
 
Old 08-22-2013, 04:26 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
assuming it starts with ?
Code:
rm \?<tab>
<tab> is tab key.. hit it a few time to make certain
 
Old 08-22-2013, 04:57 AM   #3
bison72
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi firerat,

Thanks for reply. I have a very weird yet long name which was accidentally created as below:

???>???>???>???>??&>???>*??>???>*??>L??>L??>???>L??>???=???>???=???>???>lN?>lN?>??O>?m?>?I%>?I%>?I%>

and it can't be deleted using the way you showed me.Would be appreciated if you know the way to delete this nuisance.
 
Old 08-22-2013, 05:03 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by bison72 View Post
Hi firerat,

Thanks for reply. I have a very weird yet long name which was accidentally created as below:

???>???>???>???>??&>???>*??>???>*??>L??>L??>???>L??>???=???>???=???>???>lN?>lN?>??O>?m?>?I%>?I%>?I%>

and it can't be deleted using the way you showed me.Would be appreciated if you know the way to delete this nuisance.
Try this...
Code:
find . -iname '\?*'
If that shows the file you want, and ONLY that file then...

Code:
find . -iname '\?*' |xargs rm -f
 
Old 08-22-2013, 05:05 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
As you can list it, simply place in single quotes:
Code:
rm '???>???>???>???>??&>???>*??>???>*??>L??>L??>???>L??>???=???>???=???>???>lN?>lN?>??O>?m?>?I%>?I%>?I%>'
 
Old 08-22-2013, 05:51 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
I think that is not exactly the file name, but the file name rendered using ? to substitute for "unknown characters". This kind of requires USING the ? to remove the file.

One way, a bit slow if you have lots of files, is to use "rm -i *". Since this is an interactive delete rm will query on each file and you can answer "no" for each one that ISN'T the file to delete.

Another way is to delete by inode. The technique is to first identify the inode, then use that combined with find to execute the rm on the associated filename (whatever it is). This is discussed in

http://www.cyberciti.biz/tips/delete...de-number.html


Basically, using ls -i to list the files with their inode number. Then pick the inode in question and do:

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

The interactive delete is just to be absolutely sure you have the right file to delete.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rename a directory filename with " \ " character d4v3 Linux - Newbie 8 06-07-2011 06:45 PM
[SOLVED] "tail -n 1 filename" error while "head -n 1 filename" is ok? type8code0 Linux - Newbie 3 03-21-2011 06:10 AM
[SOLVED] Script to remove lines in a file with more than "x" instances of any character ? pissed_budgie Programming 12 10-08-2010 08:16 PM
"tar - filename reads nul character" when compiling gtk-gnutella 0.96.3 HunterLoftis Linux - Laptop and Netbook 2 03-30-2007 07:58 AM
remove folder that stats with a "special" character mago Linux - General 3 06-27-2006 04:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration