Thanks everyone for your responses on this.  I've got it now and learned
a bit in the process.

Thanks very much,
It's so great that there is a community out there to talk to and learn
from.

joan

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mordechai T.
Abzug
Sent: Friday, March 31, 2006 1:18 PM
To: [EMAIL PROTECTED]
Cc: Solaris-Users mailing list
Subject: Re: tool for parsing

On Fri, Mar 31, 2006 at 11:45:55AM -0500, Grindell, Joan M. wrote:

>       I need to write a script/execute a command and don't have a lot
> of time to research.  The script will take in the output from the ls
> -al command and evaluate only the first 10 characters (the file type
> and permissions). I want to copy out all the lines that have
> -********T or -********t in the file permissions indicators.  What
> is the best to do this?

You also CCd a Solaris group.  Are you looking for Linux or for
Solaris?

With GNU find (default for Linux distros, available as an option for
recent Solaris), I would do this similar to how Banz did it:

find . -type f ! -perm -01000 -maxdepth 1

The "-type f" assumes you want only files (ie. starting with "-") and
the "maxdepth 1" limits you to the current directory.

If you do not have GNU find:

ls -al|grep -v '^-........[tT]'

This actually says that you are only excluding files with the sticky
bit set, not other entries with the sticky bit set.  The latter would
be:

ls -al|grep -v '^.........[tT]'

If you're building some kind of script that works in the general case
and that does something further, you might want to think about using
perl or GNU find + GNU xargs so that filenames with embedded newlines
and quote characters work correctly.

Here is how you might to that in GNU find + GNU xargs:

find . -type f ! -perm -01000 -maxdepth 1 -print0 | xargs -0r chmod +t

And in perl:

perl -le 'foreach my $file (glob("*"), glob(".*")) { print $file if not
(-f $file and -k $file)}

The "-f" restricts you to files; the -k looks at the sticky bit.

Have fun, and good luck.

Good luck.

- Morty

***********************************************************
You are receiving this email because you are subscribed to
the list "UMBCLINUX".  To unsubscribe, send an email to
"[EMAIL PROTECTED]" with the message(not subject):
unsub UMBCLINUX

_______________________________________________
Solaris-Users mailing list
[email protected]
http://www.filibeto.org/mailman/listinfo/solaris-users

Reply via email to