[ale] THANKS to all who replied to "ls -rt | rm -i" problem, BUT...
Courtney Thomas
cc.thomas at earthlink.net
Fri Mar 17 11:15:22 EST 2006
Personally finding awk awkward...no wait,...impenetrable, if $NF is the
last field, and the 6th field is desired to sort on, $NF -
<wanted_field#> since $NF is last, can you say "$NF + 5" OR "$NF -
<wanted_field#>"... to get to the wanted date field ?
Appreciatively,
Courtney
Geoffrey wrote:
> Joe Knapka wrote:
>
>>Geoffrey wrote:
>>
>>>Joe Knapka wrote:
>>>
>>>
>>>>Hi Courtney,
>>>>
>>>>This worked for me just now, to interactively
>>>>remove files modified on March 15:
>>>>
>>>>rm -i $(ls -l | grep 'Mar 15' | cut -d ' ' -f 9)
>>>
>>>rm -i $(ls -l |awk '/Mar 15/ {print $NF}'
>>>
>>>Will save you a WHOLE pipe and a process!
>>
>>Oh well. The machine will happily execute either one,
>>and I doubt it will care ;-) Plus, I don't know
>>awk, so the latter part of your command is
>>somewhat mysterious to me. Especially the part
>>where you omit the trailing paren; why does
>>that work?
>
>
> Ooops, it doesn't.... :(
>
> rm -i $(ls -l |awk '/Mar 15/ {print $NF}')
>
>
>>>Be aware that file names with spaces in them will screw up your efforts. :(
>>
>>That's a serious issue, and an excellent reason
>>to prefer your solution. I never put spaces in
>>filenames, and usually if someone sends me a file
>>with a space in the name, I write that person out
>>of my will at once.
>
>
> Actually, the awk solution won't work either, because NF is the number
> of fields and would simply pass the last field of the ls output.
>
> This could be extended to handle this issue, but I'm too busy to deal
> with it right now. :(
>
More information about the Ale
mailing list