LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to create directory in an existing directory with single command (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-directory-in-an-existing-directory-with-single-command-4175486323/)

Tauatioti 11-30-2013 04:55 AM

Thanks guys for the helps

Tauatioti 11-30-2013 05:27 AM

Hi

How can i delete hidden file inside a directory

Code:

rm -rf directory_name/".hidden*"
rm -rf directory_name/.hidden*

but when i do
Code:

ls -a
the .hidden file is still there,

any suggestion much appreciated

thanks

druuna 11-30-2013 05:33 AM

Is this what you are looking for:
Code:

ls -la Test/
total 20
drwxr-x--- 2 druuna druuna  4096 nov 30 12:31 .
drwxr-x--- 3 druuna druuna 16384 nov 30 12:30 ..
-rw-r----- 1 druuna druuna    0 nov 30 12:31 .bar
-rw-r----- 1 druuna druuna    0 nov 30 12:31 .foo
-rw-r----- 1 druuna druuna    0 nov 30 12:31 .1fubar

$ rm Test/.[a-z0-9]]*
$ ls -la Test/
total 20
drwxr-x--- 2 druuna druuna  4096 nov 30 12:32 .
drwxr-x--- 3 druuna druuna 16384 nov 30 12:30 ..


Tauatioti 11-30-2013 06:02 AM

i just created a hidden file using the step below

Code:

taati@taati-Dell-System-Inspiron-N7110:~/Desktop$ mkdir test
taati@taati-Dell-System-Inspiron-N7110:~/Desktop$ cd test
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ touch .hidden
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ ls
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ ls -a
.  ..  .hidden
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$

My question is how can i delete the hidden file that has been created using the single command

i already tried

rm -rf test/.*
rm -rf test/{.hidden}
rm -rf test/.??*

output
Code:

taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ rm -rf test/.*
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ cd test
bash: cd: test: No such file or directory
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ ls -a
.  ..  .hidden
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ rm -rf test/{.hidden}
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$ ls -a
.  ..  .hidden
taati@taati-Dell-System-Inspiron-N7110:~/Desktop/test$

thanks

druuna 11-30-2013 06:20 AM

My example from post #18 removes all hidden files that start with a-z or 0-9.

If you only want to delete .hidden:
Code:

$ rm test/.hidden

Madhu Desai 11-30-2013 06:47 AM

Quote:

Originally Posted by Tauatioti (Post 5072911)
i already tried

rm -rf test/.*
rm -rf test/{.hidden}
rm -rf test/.??*

You didn't try third option...

Code:

rm test/.??*
rm test/.[^.]*

And while we are in this topic, which i remembered now, and with due respect to Tauatioti, i would like to put my another question. Hope its OK with Tauatioti.

How to display all directory tree including hidden. Searched net, but could not find.

Code:

mkdir -p topdir/{1/2/3,one,.a/.b/.c}
Tried
Code:

$ shopt -s globstar

$ ls -laRd topdir/**/
drwxrwxr-x. 5 madhu madhu 4096 Nov 30 18:04 topdir/
drwxrwxr-x. 3 madhu madhu 4096 Nov 30 18:04 topdir/1/
drwxrwxr-x. 3 madhu madhu 4096 Nov 30 18:04 topdir/1/2/
drwxrwxr-x. 2 madhu madhu 4096 Nov 30 18:04 topdir/1/2/3/
drwxrwxr-x. 2 madhu madhu 4096 Nov 30 18:04 topdir/one/

But not able to resolve how to also see hidden directory tree (.a/.b/.c). I only want to know is it possible using ls, so please no find, grep and tree -ad.

prithvi.jeni 08-05-2014 10:15 PM

Create Collaborative directory
 
Setup a collaborative directory /documents/sysadmin.
The directory should be group owned by the group sysadmins and the group should own the files inside the directory.
The directory should be readable and writeable to the group owners and others should not have any access.


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