[Tutor] ls *.py[co] >> .hidden
Steven D'Aprano
steve at pearwood.info
Thu May 21 16:39:32 CEST 2015
On Thu, May 21, 2015 at 12:55:13PM +0000, Albert-Jan Roskam via Tutor wrote:
> Hi,
>
> I would like to hide .pyc and .pyo files because they are visually
> distracting. Is the aforementioned command the best way? [1].
It isn't clear what you mean by "hide them".
If you mean that you want to use the ls command to get a directory
listing, but just not see the .pyc files, then all you need is:
ls *.py
which will list the .py files and nothing else.
You can remove the .pyc and .pyo files, or move them elsewhere:
rm *.py[co]
mv *.py[co] some/other/directory/
and let Python recreate them as needed.
If you're using a GUI file manager, there may be an option to hide
certain files. I know that KDE 3, at least, hides files starting with a
leading dot, and backup files ending with ~ so it's quite likely that
there's a way to hide .pyc and .pyo files. Check the documentation for
your GUI file manager.
The command you give:
ls *.py[co] >> .hidden
doesn't hide anything. It lists the .pyc and .pyo files, but rather than
printing to the terminal, it appends them to a file called .hidden in
the current directory.
Ah, wait, I see! Nautilus uses the .hidden file to suppress the display
of those files.
I wonder whether putting a single line:
.*py[co]
inside .hidden will work? You need to try it, or ask a Gnome expert.
--
Steve
More information about the Tutor
mailing list