[Tutor] ls *.py[co] >> .hidden

Laura Creighton lac at openend.se
Thu May 21 17:52:35 CEST 2015


In a message of Thu, 21 May 2015 15:54:20 +0100, Bod Soutar writes:

>ls *.pyc *.pso >> .hidden
>
>should work
>
>root at localhost:~# mkdir hide_test
>root at localhost:~# cd hide_test/
>root at localhost:~/hide_test# touch a.pyc b.pyc c.pyo d.py e.txt
>root at localhost:~/hide_test# ls
>a.pyc  b.pyc  c.pyo  d.py  e.txt
>root at localhost:~/hide_test# ls *.pyc *.pyo >> .hidden
>root at localhost:~/hide_test# cat .hidden
>a.pyc
>b.pyc
>c.pyo
>root at localhost:~/hide_test#
>
>As this adds specific results of ls you will need to schedule the
>command through cron to get it to automatically add new files
>
>-- Bodsda

If you keep appending the results of ls to your .hidden file
it will grow to enormous size.  (Cron will be happy to do that
for you. :) ) So, if all you care about
is the files you have _today_  then use > not >> so that the
file is recreated.  If, on the other hand, you want your .hidden
to list files that you had at one time, don't happen to have now,
but want to have hidden if ever you should make them again, then
you need to periodically run the commands
sort -u .hidden >newhidden #or whatever you want to call it
mv newhidden .hidden

Laura


More information about the Tutor mailing list