Re: Remember your pearls [was grep, maybe]

2010-01-18 Thread James R. Van Zandt
(My email backlog is pretty long...) I have several scripts in $HOME/bin or /usr/local/bin, but for commands used in a particular directory, I usually just add the line to a plain text file cmd in that directory. Sometimes it will be convenient to execute the whole file as a script, but more

Re: Remember your pearls [was grep, maybe]

2009-11-03 Thread Bill McGonigle
On 10/30/2009 08:32 AM, Ben Scott wrote: They get saved in a file under $HOME/bin under an appropriate name, with appropriate comments. Ideally, I turn them into a working command I can then use as needed. (Occasionally they get turned into shell aliases or functions, if the mood strikes

Re: Remember your pearls [was grep, maybe]

2009-11-03 Thread Ben Scott
On Tue, Nov 3, 2009 at 5:09 PM, Bill McGonigle b...@bfccomputing.com wrote: same here - any conclusions as to whether they should be named 'verbnoun' or 'nounverb'? You could do both with a hard link. (I'm not sure if I'm kidding or not.) -- Ben

Re: grep, maybe

2009-10-30 Thread Ken D'Ambrosio
After a night's sleep, I realized I might even be able to make Ben happy: #!/bin/sh cd /path/to/toplevel/dir find -type d | while read i do grep moe $i/* /dev/null echo $i done | while read d do mv $d /path/to/destination || echo mv for $d didn't work: $? done -Ken P.S. It deals

Re: Remember your pearls [was grep, maybe]

2009-10-30 Thread Tom Buskey
On Thu, Oct 29, 2009 at 11:01 PM, Greg Rundlett (freephile) g...@freephile.com wrote: Not an answer to the OP, but a follow-on. So, you've worked out a magnificent one-liner solution to a interesting and recurring task. How do you 'remember' your solution? Do you create a file with

Re: Remember your pearls [was grep, maybe]

2009-10-30 Thread Ben Scott
On Thu, Oct 29, 2009 at 11:01 PM, Greg Rundlett (freephile) g...@freephile.com wrote: So, you've worked out a magnificent one-liner solution to a interesting and recurring task.  How do you 'remember' your solution? They get saved in a file under $HOME/bin under an appropriate name, with

Re: grep, maybe

2009-10-30 Thread Ben Scott
On Fri, Oct 30, 2009 at 8:15 AM, Ken D'Ambrosio k...@jots.org wrote: ... might even be able to make Ben happy ... Oh, a challenge, eh? ;-) cd /path/to/toplevel/dir find -type d | while read i Could be just: find /path/to/toplevel/dir -type d | while read i  grep moe $i/*

Rosen's signature (was: grep, maybe)

2009-10-30 Thread Ben Scott
On Fri, Oct 30, 2009 at 12:52 AM, Joshua Judson Rosen roz...@geekspace.com wrote: Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.   Okay, I'll ask: What does that stuff to the right mean? The other half of the whole habanero pepper. :) Clear as mud! ;-) More lucidly: a combinator. ;)

Re: Remember your pearls [was grep, maybe]

2009-10-30 Thread Ben Scott
On Fri, Oct 30, 2009 at 8:32 AM, Tom Buskey t...@buskey.name wrote: I wonder how much data got lost because it was kept in a format that changed.  Like Wordperfect, dbase, etc... ... the original video of the first moonwalk ... HHOS. -- Ben ___

Re: Remember your pearls [was grep, maybe]

2009-10-30 Thread Kevin D. Clark
Ben Scott writes: On Thu, Oct 29, 2009 at 11:01 PM, Greg Rundlett (freephile) g...@freephile.com wrote: So, you've worked out a magnificent one-liner solution to a interesting and recurring task.  How do you 'remember' your solution? They get saved in a file under $HOME/bin under an

grep, maybe

2009-10-29 Thread Maurice
Looking for some guidance; I have several files within several folders (5 files per folder, and thousands of folders) that I need to search a text file within each folder for a word match (like three_little_pigs.txt, and I need to find moe, if he's listed) and then when a match is found I need

Re: grep, maybe

2009-10-29 Thread Drew Van Zandt
grep -r greps all files recursively. grep -l outputs only the names of files which contain matching text. To move the folders, you would have to process that output to select the directory, then move the directory. Probably a perl or shell scripting task. AFAIK grep has nothing so specific as

Re: grep, maybe

2009-10-29 Thread Ben Scott
On Thu, Oct 29, 2009 at 11:38 AM, Maurice mauri...@cds-cumberland.org wrote: I need to search a text file within each folder for a word match (like three_little_pigs.txt, and I need to find moe, if he's listed) and then when a match is found I need to move (not copy) that entire folder (and

Re: grep, maybe

2009-10-29 Thread mark
On Thu, Oct 29, 2009 at 11:38 AM, Maurice mauri...@cds-cumberland.orgwrote: Looking for some guidance; I have several files within several folders (5 files per folder, and thousands of folders) that I need to search a text file within each folder for a word match (like three_little_pigs.txt,

Re: grep, maybe

2009-10-29 Thread Joshua Judson Rosen
mark prg...@gmail.com writes: On Thu, Oct 29, 2009 at 11:38 AM, Maurice mauri...@cds-cumberland.org wrote: Looking for some guidance; I have several files within several folders (5 files per folder, and thousands of folders) that I need to search a text file within each folder for a

Re: grep, maybe

2009-10-29 Thread Ken D'Ambrosio
Oooh! A challenge! Here's my solution: #!/bin/sh cd /path/to/toplevel/dir find -type d | while read i do grep moe $i/* mv $i /path/to/destination || echo mv didn't work: $? done -Ken On Thu, October 29, 2009 1:31 pm, mark wrote: On Thu, Oct 29, 2009 at 11:38 AM, Maurice

Re: grep, maybe

2009-10-29 Thread Ben Scott
On Thu, Oct 29, 2009 at 2:31 PM, Ken D'Ambrosio k...@jots.org wrote: find -type d | while read i do grep moe $i/* mv $i /path/to/destination || echo mv didn't work: $? done Hmmm, does the find execute concurrently with the grep? If it does, then you're liable to confuse the hell out of

Re: grep, maybe

2009-10-29 Thread Ben Scott
On Thu, Oct 29, 2009 at 2:20 PM, Joshua Judson Rosen roz...@geekspace.com wrote:    grep --recursive --files-with-matches $searchstring $topdir \    | xargs --max-args=1 dirname \    | sort --unique \    | xargs mv --target-directory=$newloc I like it. I didn't know about the

Re: grep, maybe

2009-10-29 Thread Ken D'Ambrosio
Interesting point. Three replies: 1) If you're mv'ing onto the same filesystem, the inodes will never change, and it won't matter. 2) I imagine grep will only spit out a status (which is what the parses) after it's finished running, though I'd have to verify that empirically. 3) You can cheat,

Re: grep, maybe

2009-10-29 Thread Ken D'Ambrosio
Wups! Sorry -- I read your question wrong: Does *find* run concurrently*. I'd had other concerns, and mis-read your question to fit my thinking. D'oh! It's been my experience that find doesn't get confused, it just gets miffed, and moves on. -Ken On Thu, October 29, 2009 5:03 pm, Ken

Remember your pearls [was grep, maybe]

2009-10-29 Thread Greg Rundlett (freephile)
Not an answer to the OP, but a follow-on. So, you've worked out a magnificent one-liner solution to a interesting and recurring task. How do you 'remember' your solution? Do you create a file with scripts and comments? Do you post it in a wiki? A blog? An IDE with snippets? Do you remember it

Re: grep, maybe

2009-10-29 Thread Joshua Judson Rosen
Ben Scott dragonh...@gmail.com writes: On Thu, Oct 29, 2009 at 2:20 PM, Joshua Judson Rosen roz...@geekspace.com wrote: Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr. Okay, I'll ask: What does that stuff to the right mean? The other half of the whole habanero pepper. :) More