LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-17-2018, 09:17 AM   #1
Jim232
Member
 
Registered: Apr 2018
Posts: 53

Rep: Reputation: Disabled
How to remove directory with asterisk in name - "root*"


OK, I have painted myself into a corner , again.
I used "Remote File Path" as "/root*" .
Now I am having some issues with my crosscompiler (TCF) and like to get rid of the "asterisk" in root*.
Here is what I have done so far.
I am really at lost why using same command I got two different outputs from ls. One with the "root*" and one without.

FYI - I am not sure if the TCF can "create " "Remote File Path", but it works as a default from "root" and I have in no postilion to try to change that.

Code:
root@pi:~# cd ..
root@pi:/# ls
bin   boot.bak	etc   home*  lost+found  mnt  proc  root*  sbin  sys  usr
boot  dev	home  lib    media	 opt  root  run    srv	 tmp  var
root@pi:/# rm home*
rm: cannot remove 'home': Is a directory
root@pi:/# rm root*
rm: cannot remove 'root': Is a directory
root@pi:/# cd root*
root@pi:~# ls
root@pi:~# ls 
root@pi:~# cd ..
root@pi:/# ls
bin   boot.bak	etc   lib	  media  opt   root  sbin  sys	usr
boot  dev	home  lost+found  mnt	 proc  run   srv   tmp	var
root@pi:/# cd ..
root@pi:/# ls
bin   boot.bak	etc   lib	  media  opt   root  sbin  sys	usr
boot  dev	home  lost+found  mnt	 proc  run   srv   tmp	var
root@pi:/# ls
bin   boot.bak	etc   lib	  media  opt   root  sbin  sys	usr
boot  dev	home  lost+found  mnt	 proc  run   srv   tmp	var
root@pi:/#
 
Old 10-17-2018, 09:20 AM   #2
bradvan
Member
 
Registered: Mar 2009
Posts: 367

Rep: Reputation: 61
Code:
rm -r home\* root\*
should do it.
 
Old 10-17-2018, 09:24 AM   #3
muhammednavas
Member
 
Registered: Nov 2006
Location: India
Distribution: CentOS, Redhat, Ubuntu
Posts: 30

Rep: Reputation: 15
rm -r home\* root\*


--------------
Get my Linux beginner course on udemy at 95% Discount
<advertising link removed by moderator - this section is not an LQ signature and should not be made to appear that way>

Last edited by rtmistler; 10-17-2018 at 10:24 AM.
 
Old 10-17-2018, 10:01 AM   #4
Jim232
Member
 
Registered: Apr 2018
Posts: 53

Original Poster
Rep: Reputation: Disabled
????




Quote:
pi@pi:~ $ rm -r home\* root\*
rm: cannot remove 'home*': No such file or directory
rm: cannot remove 'root*': No such file or directory
pi@pi:~ $
root@pi:/# ls
bin boot.bak etc lib media opt root sbin sys usr
boot dev home lost+found mnt proc run srv tmp var

Last edited by Jim232; 10-17-2018 at 10:03 AM.
 
Old 10-17-2018, 10:04 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
just like it says,
[code]
rm -r root\*
[\code]
is escaping \ the * so it sees it as a * and not a wildcard.

just be leery when using -r with rm
if you want to keep the directory and just rename it replace rm with mv
Code:
move root\* root
example
Code:
┌─[userx@parrot]─[~]
└──╼ $mkdir oops*
┌─[userx@parrot]─[~]
└──╼ $ls
 Desktop     Downloads   Music    Pictures   Templates
 Documents   Dropbox    'oops*'   Public     Videos
┌─[userx@parrot]─[~]
└──╼ $mv oops\* oops
┌─[userx@parrot]─[~]
└──╼ $ls
Desktop    Downloads  Music  Pictures  Templates
Documents  Dropbox    oops   Public    Videos



rmdir oops
yours explained
Code:
root@pi:~# cd ..
root@pi:/# ls
bin   boot.bak	etc   home*  lost+found  mnt  proc  root*  sbin  sys  usr
boot  dev	home  lib    media	 opt  root  run    srv	 tmp  var
root@pi:/# rm home*
rm: cannot remove 'home': Is a directory
root@pi:/# rm root*
rm: cannot remove 'root': Is a directory
root@pi:/# cd root*
root@pi:~# ls
root@pi:~# ls 
root@pi:~# cd ..
root@pi:/# ls
bin   boot.bak	etc   lib	  media  opt   root  sbin  sys	usr
boot  dev	home  lost+found  mnt	 proc  run   srv   tmp	var
root@pi:/# cd ..
root@pi:/# ls
bin   boot.bak	etc   lib	  media  opt   root  sbin  sys	usr
boot  dev	home  lost+found  mnt	 proc  run   srv   tmp	var
root@pi:/# ls
bin   boot.bak	etc   lib	  media  opt   root  sbin  sys	usr
boot  dev	home  lost+found  mnt	 proc  run   srv   tmp	var
root@pi:/#
rm will only remove dir if it is empty, else it fails, this is why rm -r is used to remove contents within dir first then the directory because everything is seen as a file, even directories.

why home and root no got the * asterisk anymore, don't know, what did you do?

Last edited by BW-userx; 10-17-2018 at 10:20 AM.
 
Old 10-17-2018, 12:52 PM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Nothing against the \* (character quoting by a backslash prefix),
but I find the "string" quoting less error-prone.
Code:
mkdir "/home*"
rmdir "/home*"
You remove it like you created it.
 
  


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
How to remove "domain\" from UserID and GroupID using Active Directory. jxfish2 Red Hat 0 09-28-2018 11:45 PM
"cannot create temporary directory for the root file system: No space left on device", but df-h says home and root are 77% and inodes are OK roberto32 Linux - General 3 05-27-2018 07:34 AM
[SOLVED] Terminal directory in Backtrack 5 changed from "root@bt~#" to "sh-4.1# mdtmaverick Linux - Newbie 2 09-17-2012 02:44 PM
".config" and ".kde" folders are being created under root directory (Slack Current) piratesmack Slackware 8 03-12-2011 11:06 PM
issue with mv: "inter-device move failed, unable to remove target: Is a directory " Xeratul Debian 3 12-06-2010 02:46 AM

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

All times are GMT -5. The time now is 01:17 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
Open Source Consulting | Domain Registration