SUMMARY: Simple shell question

From: Nicholas Masika (nmasika@whiz.mfi.com)
Date: Wed Jun 24 1998 - 18:44:07 CDT


Oh boy, do I feel dumb (I knew this was a simple question)...

The consensus is:

ls -1 | grep -v .BAK

This is a great list. I got this answer in about 10 minutes from:

Jeff Wasilko [jeffw@smoe.org]
Sanjaya Srivastava [Sanjaya.Srivastava@Eng.Sun.COM]
Jamie Lawrence [jal@ThirdAge.com]
Otto, Doug (Exchange) [dotto@alldata.com]
Derek Terveer [derek.terveer@ci.saint-paul.mn.us]
Ray Smith [rcsmith@csc.com]
fciobanu@credit.erin.utoronto.ca
Jim Roy [jim@nga.com]
Graham Leggett [graham@vwv.com]
Don Lewis [Don.Lewis@tsc.tdk.com]
Karl Vogel [vogelke@c17mis.region2.wpafb.af.mil]
and I'm sure there will be a *flood* of mail coming my way :-)

Original question:

We sys admins frequently have to write shell scripts to get somthing
done and I've just been stumped by something that I think is rather
simple...

To get a list of all files with a .BAK suffix, you would simply use
echo *.BAK. Is there an easy way to get a list of the files in a
directory that do *not* have the .BAK suffix?

I suppose something like:
for i in *
do
  if [ `expr $i : '.*\.BAK$'` -eq 0 ]; then
    echo $i
  fi
done

would work but I'm looking for something simpler...

Will summarize, of course, promptly.



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:42 CDT