[kwlug-disc] ncurses file selection tool

Khalid Baheyeldin kb at 2bits.com
Fri Jan 15 14:45:08 EST 2021


I use a set of steps to do the same thing, although they are more involved.
The awk program is where it all is ...

To rename files, I generate a script like this:

ls | grep "whatever" | awk '{print "mv ", $1, $1}' > x
# Edit using vim to remove the lines for the files I want to keep
sh x

To delete files, it is like this:

ls | grep "whatever" | awk '{print "rm ", $1}' > x
# Edit using vim to remove the lines for the files I want to keep
sh x

The grep in both cases is any filter on file names.

On Thu, Jan 14, 2021 at 4:01 PM Chris Frey <cdfrey at foursquare.net> wrote:

> Thank you!  I've used the first two steps, but not the execution step.
> That was the missing piece.
>
> - Chris
>
>
> On Thu, Jan 14, 2021 at 12:52:13PM -0500, Doug Moen wrote:
> > I use a brutally primitive subset of vim.
> >
> > Open a new buffer.
> >
> >     :r ls
> >
> > reads a list of files from the current directory into the buffer.
> > Then, edit the buffer into a shell script. Eg, to remove all the files,
> >
> >     :%s,^,rm ,
> >
> > Delete any lines that remove files you don't want to remove.
> > Then run the shell script:
> >
> >     :w !sh
> >
> > I don't general use this technique just to remove files, usually the
> commands are more complicated. That was just an example.
> >
> > The benefit of this technique is that it is Turing complete. I can
> accomplish anything. I don't have to learn a new tool, and I don't run into
> the limitations that high level tools usually suffer from.
> >
> > _______________________________________________
> > kwlug-disc mailing list
> > kwlug-disc at kwlug.org
> > https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> https://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>


-- 
Khalid M. Baheyeldin
2bits.com, Inc.
Fast Reliable Drupal
Drupal performance optimization, hosting and consulting.
"Sooner or later, this combustible mixture of ignorance and power is going
to blow up in our faces." -- Dr. Carl Sagan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20210115/4ee23806/attachment.htm>


More information about the kwlug-disc mailing list