[aklug] Re: sed regex help needed

From: Kevin Miller <atftb2@alaska.net>
Date: Tue Nov 17 2009 - 13:01:49 AKST

Kenneth D Weinert wrote:
> Well, actually, you'd want to change -f2 to -f2-3 to get both fields. In
> this case you could also use -f2,3 (the first is a range of fields, the
> second is selected fields.)

Opps -my mistake. I actually did the latter. Well spotted.

> The cut command is a nice way to extract fields from a directory listing
> as well, but since cut treats each separator as a separator (that is, a
> set of X adjacent separators are treated as X fields, not 1 field) the
> trick is to run the output of ls through a tr -s ' ' first:
>
> ls -l | tr -s ' ' | cut -d' ' -f5,8-
>
> will list the file size and name of the files in your directory (you may
> need to adjust the field numbers if your ls is different.)
>
> the 8- is to account for file names with embedded spaces.
>
> Sorry for the cli lesson here, but getting info from an ls is a somewhat
> common occurrence and it can be just a tiny bit frustrating when you
> first try it :) Don't ask me how I know. :)

Hey, don't apoligize! A good cli tip is invaluable. Thanks...

-- 
Kevin Miller
Juneau, Alaska
http://www.alaska.net/~atftb
In a recent poll, seven out of ten hard drives preferred Linux.
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Tue Nov 17 13:02:42 2009

This archive was generated by hypermail 2.1.8 : Tue Nov 17 2009 - 13:02:42 AKST