What are the commands to make a file hidden and to delete all hidden files in the folder?

Showing Answers 1 - 9 of 9 Answers


  • Nov 16th, 2007

Rename the file so that it starts with (.)
For example if you have a file called file.txt just rename it to .file.txt
mv file.txt .file.txt

  Was this answer useful?  Yes

To hide the files simply rename the file with mv command like filename follows with a dot(.).

$mv filename .filename
To see the hidden files
$ls -a
To remove the hidden files
$rm .*

  Was this answer useful?  Yes


  • Jan 19th, 2016

rm -rf .* will delete all files present in all current directories. but suppose you have to delete file in a particular directory. we can use find.
find dir -type f -name .* -maxdepth 3|xargs rm -f
find dir -type f -name .* -maxdepth 3 exec rm -f {} ;

  Was this answer useful?  Yes


  • Jan 31st, 2016

find . -maxdepth 1 -name ".*" -type f -delete
mv filename .filename

  Was this answer useful?  Yes

Yugandhar reddy

  • Sep 24th, 2016

rm `ls -a | grep "^." | tail -n +3` # for removing all hidden files
mv file .file # for making a file hidden

  Was this answer useful?  Yes

Anupam Kumar

  • Oct 27th, 2016

To hide a file- mv filename1.dat .filename.date
to remove only hidden file-

  1. $ ls -l | awk {print $9} > file1.txt

  2. $ ls -la | awk {print $9} > file2.txt

  3. $ rm "comm -2 file1.txt file2.txt"

  Was this answer useful?  Yes


  • Sep 14th, 2017

mv file.txt .file.txt ----for making file hidden
rm .* -------for deleting hidden files.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions