[Herts] RE: Debian Install

Ian Gregory yahoo at zenatode.org.uk
Tue Feb 17 00:59:24 GMT 2004

On Mon, Feb 16, 2004 at 11:44:17PM +0000, Mr. Spock wrote:
> P.S. Just for the record, how many other Debian users read HertsLUG?

Just for the record, I do. But only as a user of a shell account
on a server running Debian. If I were to run my own Linux box
Debian would be my first choice, but I have enough on my plate
with Mac OS X and Solaris to keep me occupied for a while.

In a previous email Mr Spock suggested we post top tips for
working with the dreaded (to those coming from Windoze anyway)
command line, well here are a couple:

Say you want to find all files in /etc (or any subdirectory of
/etc) that have a .foo extension and have been modified in the
last 3 days. Well, "find" is your friend:

find /etc -type f -name \*.foo -mtime 3

"-type f" is perhaps not necessary, it limits the output to files
(as opposed to directories, device files, symbolic links etc)

the backslash in "\*.foo" protects "*" from the shell - if you
didn't escape it with the backslash then the shell would look
for files matching *.foo in the current directory and pass them
all (if any) to "find" which would then give unexpected results.

What if you also wanted to delete all these files? Well you could
add "-exec rm {} \;" to the end of the command. This causes rm
to act on every file found. The semicolon is required, but again
has to be escaped to avoid it being interpreted by the shell.

Read the man page for further examples and details.


Or how about if you just want to change the .foo extension to .bar
for all files in the current directory. Instead of find you could
just use the shell like this:

for file in *.foo
mv $file ${file%foo}.bar

Ian Gregory

More information about the Herts mailing list