LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 09-16-2013, 11:31 AM   #1
red_ifo
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Rep: Reputation: Disabled
Removing folder named ~ inside directory


I realize that ~ is a shortcut to your home directory, but I've got a directory that contains files, folders, and a folder named ~. And of course if I try to go to that folder I end up in my home folder. If I try to delete the containing directory, it starts deleting from my home folder. It doesn't look like a symbolic link, just a normal folder named ~. How do I remove this folder from the directory?

Thanks for any help here!
 
Old 09-16-2013, 11:33 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,028

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
maybe one of these would work:
Code:
rm ./~
rm \~
rm '~'
 
Old 09-16-2013, 11:40 AM   #3
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,185
Blog Entries: 10

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
You can delete a file with strange characters (especially hidden characters) by itís inode number.

To find the inode number of a file, list the directory with the -i option:

Code:
ls -i "~"
quoting "~" should keep ~ from expanding to /home/user...YMMV

Note the inode number of the file "~"

Use the find command to delete the file by itís inode number:

Code:
find . -inum nnnnnnn -exec echo rm {} \;
Warning:
ECHO is a 'dry-run', remove once the correct file has been verified.


Alternate solution, use a graphical File Manager.
 
Old 09-16-2013, 11:46 AM   #4
red_ifo
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you for the quick replies!

I did your find command and it was telling me that it was a directory, and if I changed to rmdir then it told me it wasn't empty. I was able to get into that directory and there was a tmp directory, I deleted that and the '~' directory vanished. I've never seen that before. But thanks again for both of your suggestions, they were very helpful in getting rid of it.
 
Old 09-16-2013, 11:56 AM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,259

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Tab completion is very helpful for matching bad file/dir names.

For example
Code:
rmdir ~
followed by Tab, will complete to
Code:
rmdir \~/
which will allow you to remove it properly.
 
Old 09-16-2013, 01:42 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,185
Blog Entries: 10

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Glad it worked out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to limit max. number of folder can be created inside a folder Winanjaya Linux - General 4 08-01-2013 06:47 AM
[SOLVED] Better way to create a folder for each month, with another folder inside of each rjo98 Linux - Newbie 9 12-03-2012 11:38 AM
Virtual Box. Removing a shared folder inside virtual xp. glore2002 Linux - Software 2 05-20-2007 12:12 PM
Removing a Directory from the Terminal without deleting each file or folder lennysokol Linux - General 4 05-31-2005 12:30 AM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 03:26 AM


All times are GMT -5. The time now is 06:44 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration