[ale] When a script is necessary, and when a piped command is sufficient ?
fletch at phydeaux.org
fletch at phydeaux.org
Wed Mar 15 10:02:15 EST 2006
> I've been trying to assemble a sequence of actions, e.g. find, sort, rm,
> etc.... to filter a directory of files and have not yet succeeded.
>
> In particular I need to execute, in the following sequence;
>
> 1-find or ls
> 2-sort [by file date]
> 3-rm [interactively]
>
> I'd prefer a prompted command sequence rather than a script.
Erm, that's a false distinction. Pretty much any shell (or Perl, Ruby,
and Python for that matter) have some mechanism for reading input from the
user; see 'read' in the relevant shell man page for starters. However in
this case, rm provides an -i flag so that's not an issue.
> For example...
>
> ls -l | sort +5
>
> will print out the dir sorted by file date but I then need to rm certain
> files of a certain date, that HAS been sorted out by the above, the sort
> for putting all the files I want to remove in a contiguous sequence so
> that I can page through the others to that point quickly and
> interactively, to make sure I don't delete anything unintentionally.
And to add to the golfing . . .
zsh -c 'for i in *(.om); do rm -i $i ; done'
zsh -c 'print -N *(.om) | xargs -0 rm -i'
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org| Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U
More information about the Ale
mailing list