[ale] When a script is necessary, and when a piped command is sufficient ?

James P. Kinney III jkinney at localnetsolutions.com
Wed Mar 15 09:58:47 EST 2006


Courtney,

I would just add a bit more to the existing process. 

The output of the find and sort gets written to a tmp file. Then that
file gets cat'ed to the screen with an prompt for approval to go to the
next step.

Lastly, the rm can get changed so the prompt is to delete all or
partial. So based on your input (if reply == 'y|Y' then for i in `cat
tmpfile` do rm -f $i, else for i in `cat tmpfile` do rm -i $i).

On Wed, 2006-03-15 at 09:44 -0500, Courtney Thomas wrote:
> 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.
> 
> 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.
> 
> I've briefly and unsuccessfully attempted to pipe this into some sort of 
> "rm" operation from the command line, but failed.
> 
> I guess I could tar the directory and then filter it as a file or just 
> filter the dir from the command line, which would seem to be less 'safe' 
> and maybe for prototyping the command(s) should tar the dir,... at least 
> until the commands are safely tested,... and be the wise way to go.
> 
> Anyway, I'd gratefully accept suggestions to quickly resolve this, as 
> I've got outdoor projects backed up which I'd like to complete 'fore it 
> gets hot  :-) and would like to avoid devoting more time to this, for now.
> 
> Appreciatively,
> Courtney
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
-- 
James P. Kinney III          \Changing the mobile computing world/
CEO & Director of Engineering \          one Linux user         /
Local Net Solutions,LLC        \           at a time.          /
770-493-8244                    \.___________________________./
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part




More information about the Ale mailing list