I'm trying to hide some files with some command, I tried the rm command, but it did not work and also tried to rename but did not understand how it works. The files that I want to hide have spaces in their names and I just want to put the dot in front of the names to let them hidden. Can anyone help me?
5 Answers
Try this in the terminal
$ for i in *
> do
> mv "$i" ".$i"
> done
It hides all the files in the current directory. I hope that's what you're looking for.
EDIT: Added the quotes around $i.
- 1,701
rename 's/^/./' file1.txt 'file with spaces' 'third file.mkd'
You can of course use globs. The following will add a dot to the beginning of every file that ends with .txt:
rename 's/^/./' *.txt
Or you could hide every file beginning with foo and ending with .mkd:
rename 's/^/./' foo*.mkd
rename is using a substitute command: s/foo/bar/ replaces the first foo with bar. Instead of foo, you can also use a regular expression, and in regexes ^ means 'the beginning of the line'. So s/^/./ tells rename to 'replace the beginning of the line with a .'. That is: it places the dot before the first character.
You can also use the -n option to do a 'test run' -- with that, rename will not actually rename the files, but will list all the files that it would have changed, were you not using the -n flag.
rename -n 's/^/./' *.txt
- 4,625
To quickly hide all files of the current directory from display in Nautilus:
ls * > .hidden
This will create a list of hidden files in the file .hidden within the current directory. It will of course not hide these files on the command line, and if we chose to display hidden files from Nautilus they will show up again (as will . files).
To only hide a subset of files use appropriate wildcards, or edit the .hidden file with an editor.
To show all files again, just remove the .hidden file.
- 144,580
My prefered method is using "nautilus-hide" in "Nautilus-Actions-Extra" package:
sudo add-apt-repository ppa:nae-team/ppa
sudo apt-get update
sudo apt-get install nautilus-actions-extra nautilus-hide
nautilus -q
After selecting files/folders in Nautilus, choose (Un)Hide > Hide from the context menu.
This creates a file named ".hidden" containing a list of files/folders to be hidden.
- 11,074