School of Computing. Dublin City University.
Online coding site: Ancient Brain
coders JavaScript worlds
.* files are hidden by convention, by ls and other tools.
We can pipe commands through a program
to make other files hidden by convention.
e.g. Hide text editor backup files (things like file%, file~, file.bak):
# make some files ending in % or ~ or .bak # then see how we could exclude them from a listing: ls -al $* | grep -v "%$" | grep -v "~$" | grep -iv "\.bak$" grep -v means exclude lines that contain the pattern $ here means end-of-line ^ means start-of-line . means any character \. means the literal character '.'
Work through the following example:
# make 3 files: $ touch airflights.bakuwait.txt $ touch airflights.bakuwait.bak $ touch somebakuwait.data # list them: $ ls -l *kuwait* -rw-r--r-- 1 mhumphrysdculab tutors 0 Feb 21 11:45 airflights.bakuwait.bak -rw-r--r-- 1 mhumphrysdculab tutors 0 Feb 21 11:44 airflights.bakuwait.txt -rw-r--r-- 1 mhumphrysdculab tutors 0 Feb 21 11:45 somebakuwait.data # if we exclude any line with "bak" we exclude everything: $ ls -l *kuwait* | grep -v 'bak' # ".bak" also excludes everything! Why? $ ls -l *kuwait* | grep -v '.bak' # "\.bak" is better but still not right $ ls -l *kuwait* | grep -v '\.bak' -rw-r--r-- 1 mhumphrysdculab tutors 0 Feb 21 11:45 somebakuwait.data # "\.bak$" is what we want $ ls -l *kuwait* | grep -v '\.bak$' -rw-r--r-- 1 mhumphrysdculab tutors 0 Feb 21 11:44 airflights.bakuwait.txt -rw-r--r-- 1 mhumphrysdculab tutors 0 Feb 21 11:45 somebakuwait.data
grep -v "%$" | grep -v "~$" | grep -iv "\.bak$" so we can reuse it in directory listing: ls -al $* | filterbaks and in other programs: if test `echo $i | filterbaks` then ...Makes backup files invisible everywhere (until needed).
egrep -iv "%$|~$|\.bak$"where, inside the string here, | means "OR".
ls -l $* | filterbaks
I type "d" to see the files excluding backup files.
I type "ls" to see all the files.