[TriLUG] Slightly off topic

Dewey Hylton plug at hyltown.com
Sat Dec 6 19:27:22 EST 2014


grep and cut could have been used too, and probably a few other combinations as well. the "trick" here is simply filtering based on the first field in the 'ls -l' output, where the first character describes the file/directory/whatever type. the '-' describes a plain file. the filter could have been simplified to '/^-/' as well. i suppose there may be situations where the root user has no read access to the file, and the file would then not make the list given the longer filter ...

----- Original Message -----
> From: "William Sutton" <william at trilug.org>
> To: "Triangle Linux Users Group General Discussion" <trilug at trilug.org>
> Sent: Saturday, December 6, 2014 7:06:32 PM
> Subject: Re: [TriLUG] Slightly off topic
> 
> Nice... I didn't even think of awk, because I never use it.
> 
> William Sutton
> 
> On Sat, 6 Dec 2014, Ken MacKenzie wrote:
> 
> > That is exactly what I need, at least as far as trying it against local
> > linux install.  Monday morning I will try that against Solaris.  Thank you.
> >
> > Ken
> >
> > On Sat, Dec 6, 2014 at 12:31 AM, Dewey Hylton <plug at hyltown.com> wrote:
> >
> >> ls -l /somedir/ | awk '/^-r/ { print $9 }'
> >>
> >> ----- Original Message -----
> >> > From: "Ken MacKenzie" <ken at mack-z.com>
> >> > To: "Triangle Linux Users Group General Discussion" <trilug at trilug.org>
> >> > Sent: Friday, December 5, 2014 7:11:39 PM
> >> > Subject: [TriLUG] Slightly off topic
> >> >
> >> > This is probably off topic as the intended target for this command is
> >> > Sun/Solaris
> >> >
> >> > Anyway I need a single liner that will output files for me similar to ls
> >> -1
> >> > (note that is a numebr 1 not an l)
> >> >
> >> > I need it to only list "true" files as in no links and no directories
> >> > and
> >> > obviously not recurse down those.
> >> >
> >> > Also it needs to spit out a file name not a full path
> >> >
> >> > I debated using ls -1p and using grep to leave off the entries that had
> >> > a
> >> > trailing / but that does not handle the links.
> >> >
> >> > I messed with find as an option with something like this
> >> >
> >> > find somepath -name "somesearchstring" -o -type d -prune
> >> >
> >> > That worked for removing directories but before I tried removing links
> >> > as
> >> > well I noticed the output spit out the full path.
> >> >
> >> > I figured I would hit this list as you guys tend to be quick on the draw
> >> > and I would like to wrap up my work evening having this command sorted
> >> > out.  Even though I am aware it is a Friday night.
> >> >
> >> > Ken
> >> > --
> >> > This message was sent to: Dewey Hylton <plug at hyltown.com>
> >> > To unsubscribe, send a blank message to trilug-leave at trilug.org from
> >> that
> >> > address.
> >> > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> >> > Unsubscribe or edit options on the web        :
> >> > http://www.trilug.org/mailman/options/trilug/plug%40hyltown.com
> >> > Welcome to TriLUG: http://trilug.org/welcome
> >> --
> >> This message was sent to: Ken M. <ken at mack-z.com>
> >> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> >> address.
> >> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> >> Unsubscribe or edit options on the web  :
> >> http://www.trilug.org/mailman/options/trilug/ken%40mack-z.com
> >> Welcome to TriLUG: http://trilug.org/welcome
> >>
> > --
> > This message was sent to: William <william at trilug.org>
> > To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> > address.
> > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > Unsubscribe or edit options on the web	:
> > http://www.trilug.org/mailman/options/trilug/william%40trilug.org
> > Welcome to TriLUG: http://trilug.org/welcome
> --
> This message was sent to: Dewey Hylton <plug at hyltown.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
> address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web	:
> http://www.trilug.org/mailman/options/trilug/plug%40hyltown.com
> Welcome to TriLUG: http://trilug.org/welcome


More information about the TriLUG mailing list