[ale] THANKS to all who replied to "ls -rt | rm -i" problem, BUT...ATTN:JoeKnapka
Joe Knapka
jknapka at kneuro.net
Sat Mar 18 15:16:16 EST 2006
Joe Knapka wrote:
> Courtney Thomas wrote:
>
>>Thanks Joe.
>>
>>Exactly what I was lookin' for.
>>
>>I should ask though, how'd you come up with "-f 9" in cut ?
>
>
> Experimentation. I tried -f 8 first (counting the
> fields left-to-right in the 'ls -l' output), but
> found that it gave me the previous field. So I
> tried -f 9, which worked.
And probably the reason this hsppens is that "cut"
considers *every* space character a field delimiter,
so there are empty fields in the output whenever two
spaces appear next to one another.
"cut" is really a crummy tool for this IMO; there's
lots of ways it might screw up if the "ls" output
varies, which it does (for example, if the width
of a field varies, there might be different numbers
of fields per line, since "ls" will insert spaces
to make the columns line up). What's needed is really
something like Python's or Tcl's "split" function,
which considers any contiguous group of whitespace
characters to be a field delimiter. I'm not aware
of a shell function that does the same thing, but
there probably is one.
-- JK
More information about the Ale
mailing list