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 often I'll
cat to the screen, then cut and paste what I want.  For example, I
have a directory /debian/images where I put files related to burning
CDs.  I have a file cmd there with the appropriate commands for
mkisofs, cdrecord, wodim, growisofs, etc.  It's sort of a middle
ground between developing a fully working command script and just
reading the manpages.

  - Jim Van Zandt


   From: Ben Scott dragonh...@gmail.com
   Date: Fri, 30 Oct 2009 08:32:46 -0400
   Content-Type: text/plain; charset=iso-8859-1

   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 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 me.)

 Or I forget about them and have to re-invent the wheel next time. :)

   -- Ben

   ___
   gnhlug-discuss mailing list
   gnhlug-discuss@mail.gnhlug.org
   http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 me.)

same here - any conclusions as to whether they should be named
'verbnoun' or 'nounverb'?  I'm inconsistent and constantly confuse
myself. :)  The x2y scripts are a nice dodge.

-Bill

-- 
Bill McGonigle, Owner
BFC Computing, LLC
http://bfccomputing.com/
Telephone: +1.603.448.4440
Email, IM, VOIP: b...@bfccomputing.com
VCard: http://bfccomputing.com/vcard/bill.vcf
Social networks: bill_mcgonigle/bill.mcgonigle
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 gracefully with spaces (I checked -- hadn't been sure about
how the second read would work).
P.P.S.  It does appear that find is terminated for the second loop.  (Or
so said the ps I threw into it to check.)
P.^3S.  For millions of hits, your memory might start to bog.  In which
case, if you expect that, it's definitely time to go with the temporary
file thing.

On Thu, October 29, 2009 1:31 pm, mark wrote:
 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, 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 it's 3~5 files contained within) to
 another location...



 #!/bin/sh
 cd [top level directory] grep -l -r [search string in double quotes] 
 /tmp/file_names_found
 2/tmp/grep.errs
 cat /tmp/file_names_found|xargs -i basename {} /tmp/dir_names_to_move
 dir_list=`sort /tmp/dir_names_to_move|unique` for DIRECTORY in
 $(dir_list); do
 mvdir $DIRECTORY [new location here] STATUS=$?
 if [ $STATUS -ne 0 ]; then echo mvdir returned status $STATUS end done
exit

 You'll have to come up with a way to create the value for new location
 here that is unique so you don't overlay all the directories into the
 same path and lose everything, so maybe test it with a copy first.  You'll
 also want to check /tmp/grep.errs for any error messages.  I hope this
 helps.

 mark

 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is believed to be clean.

 ___
 gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/






-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 scripts and comments?
 Do you post it in a wiki?
 A blog?
 An IDE with snippets?
 Do you remember it in your head?

 I used to store my good one-liners in Konsole as 'bookmarks' because
 you could put anything into a bookmark. Until KDE4. They improved
 the bookmark system which now only knows telnet:// and ssh:// URLs.
 Konsole even re-writes your bookmarks as you save them by url-encoding
 them.  The issue is apparently due to reliance on Kurl - a core class
 in KDE, and so not a problem with Konsole.

 http://bugs.kde.org/show_bug.cgi?id=185962
 http://bugs.kde.org/show_bug.cgi?id=88867

 Greg Rundlett


Nice.

I keep text files.  I have some going back to 1996 when I used exmh email.

I wonder how much data got lost because it was kept in a format that
changed.  Like Wordperfect, dbase, etc...
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 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 me.)

  Or I forget about them and have to re-invent the wheel next time. :)

-- Ben

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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/*  /dev/null  echo $i

  Definitely should be at least:

grep moe $i/*  /dev/null  echo $i

  (Putting the star inside the quotes prevents the shell from globing
it, thus leading to grep trying to open a file named * in the
directory.)

  Could be:

grep -q moe $i/*  echo $i

  (The -q switch to grep causes it to just exit with true on the first
match, making things faster if the match is earlier in the file. Also
avoids the need to throw away the output.)

 P.S.  It deals gracefully with spaces (I checked -- hadn't been sure about
 how the second read would work).

  Yah, read reads lines.  Lines are split into tokens on spaces and
put into parameters you give, but the last parameter gets the rest of
the line.  So with one parameter, you get the whole line.

 P.P.S.  It does appear that find is terminated for the second loop.  (Or
 so said the ps I threw into it to check.)

  Cool.  Thanks for checking.  And for letting us know.  :)

 P.^3S.  For millions of hits, your memory might start to bog.  In which
 case, if you expect that, it's definitely time to go with the temporary
 file thing.

  Or increase your swap space.  ;-)

-- Ben

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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. ;)

  Ditto!  ;-)

 It's a pun. ... So
 maybe it's a deeper (or worse) joke than I originally intended

  I'll work on appreciating the finer aspects of the joke when I
understand the basics.  ;-)

 Some kind of LISP?

 Almost. Did you have any luck googling for it? :)

  Yah, I found your page, along with a while bunch of your signature
in various archives.  ;-)

  And clicking the Google link on your page yields only a handful of
results, some of which are unavailable, none of which seem to explain
things, and one of which is your page again.  ;-)

  From single-letter name ... phonetically I eventually decided it
must be Don't be afraid to ask Y, i.e., Don't be afraid to ask
why.  That leads me to finding the below in the Wikipedia article,
which at least looks kinda like your sig:

Y = λf·(λx·f (x x)) (λx·f (x x))

  I'm left thinking of that old meta-joke: Explaining a joke is like
dissecting a frog: You understand it better, but the frog dies in the
process.  ;-)

  Maybe you should put the whole sig in quotes, so people like me
don't think you're telling us not to be afraid to ask what the stuff
on the right means.  ;-)

-- Ben

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 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 me.)

aolMe too!/aol

This scheme really works for me.  For example, later this afternoon
I'm going to use a snippet of code I wrote in 2003 to analyze a ~1GB
logfile that I have been generating for over a week now.  It pays to
write clean and flexible code in the first place, and it pays to be
semi-organized as well.

Regards,

--kevin
-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 to move 
(not copy) that entire folder (and it's 3~5 files contained within) to 
another location...

I'm thinking grep, but don't know the correct syntax to make all this 
happen.
I can easily find all the folders (1949 of them) and the word match 3923 
times within the text file(s)...


Any ideas???



-- 
-Maurice Pelletier
Child Development Services - Cumberland County
50 Depot Road
Falmouth, ME 04105
207-781-8881 (voice)
207-781-8855 (fax)

www.cds-cumberland.org


Linux -- it's not just for breakfast anymore...
-Moe



___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 moving the folders the files are in,
but it gets you 80% of the way there.

--DTVZ

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, 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 it's 3~5 files contained within) to
 another location...

 I'm thinking grep, but don't know the correct syntax to make all this
 happen.
 I can easily find all the folders (1949 of them) and the word match 3923
 times within the text file(s)...


 Any ideas???



 --
 -Maurice Pelletier
 Child Development Services - Cumberland County
 50 Depot Road
 Falmouth, ME 04105
 207-781-8881 (voice)
 207-781-8855 (fax)

 www.cds-cumberland.org


 Linux -- it's not just for breakfast anymore...
 -Moe



 ___
 gnhlug-discuss mailing list
 gnhlug-discuss@mail.gnhlug.org
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 it's 3~5 files contained within) to
 another location...

  Well, the following will search for any file containing moe
(exactly), and list matching files:

grep -l -r moe /path/to/top/level/directory

  If you want a case-insensitive search (match moe, Moe, MoE, etc.):

grep -i -l -r moe /path/to/top/level/directory

  If you want to search for multiple names, separate them by vertical
bars (|).  You will have to quote the search string to keep the bars
from being interpreted by the shell:

grep -i -l -r 'moe|larry|curly' /path/to/top/level/directory

  Moving just the files would be pretty easy.  Moving the
*directories* would be trickier.  We can't move it when grep is still
in the directory, so we'll have to save a list somewhere, then parse
the list to find the directory names, then eliminate the duplicates,
then move the directories.

-- Ben
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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, 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 it's 3~5 files contained within) to
 another location...



#!/bin/sh
cd [top level directory]
grep -l -r [search string in double quotes]  /tmp/file_names_found
2/tmp/grep.errs
cat /tmp/file_names_found|xargs -i basename {} /tmp/dir_names_to_move
dir_list=`sort /tmp/dir_names_to_move|unique`
for DIRECTORY in $(dir_list); do
 mvdir $DIRECTORY [new location here]
 STATUS=$?
 if [ $STATUS -ne 0 ]; then
echo mvdir returned status $STATUS
 end
done
exit

You'll have to come up with a way to create the value for new location
here that is unique so you don't overlay all the directories into the same
path and lose everything, so maybe test it with a copy first.  You'll also
want to check /tmp/grep.errs for any error messages.  I hope this helps.

mark
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 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 it's 3~5 files contained within) to
  another location...
 
 #!/bin/sh
 cd [top level directory]
 grep -l -r [search string in double quotes]  /tmp/file_names_found  2/tmp/
 grep.errs
 cat /tmp/file_names_found|xargs -i basename {} /tmp/dir_names_to_move
 dir_list=`sort /tmp/dir_names_to_move|unique`
 for DIRECTORY in $(dir_list); do
  mvdir $DIRECTORY [new location here]
  STATUS=$?
  if [ $STATUS -ne 0 ]; then
     echo mvdir returned status $STATUS
  end
 done
 exit


I'd probably go with something like:

grep --recursive --files-with-matches $searchstring $topdir \
| xargs --max-args=1 dirname \
| sort --unique \
| xargs mv --target-directory=$newloc

The only thing that really sucks about that is that the involvement of
`sort' means that the mv needs to wait until *all* of the files have
been grep'd, instead of just moving the directory as soon as *any*
file in it is found to contain the search-term.

And, depending on whether your directories vary in the depth of their
nesting, and whether you prefer to move the more- or less-deep
directories first (or at all), you may need to add a --reverse to
the `sort' line or do more complicated filtering with an additional
grep (on the *paths*) or sed.

-- 
Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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
 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, 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 it's 3~5 files contained within) to
 another location...



 #!/bin/sh
 cd [top level directory] grep -l -r [search string in double quotes] 
 /tmp/file_names_found
 2/tmp/grep.errs
 cat /tmp/file_names_found|xargs -i basename {} /tmp/dir_names_to_move
 dir_list=`sort /tmp/dir_names_to_move|unique` for DIRECTORY in
 $(dir_list); do
 mvdir $DIRECTORY [new location here] STATUS=$?
 if [ $STATUS -ne 0 ]; then echo mvdir returned status $STATUS end done
exit

 You'll have to come up with a way to create the value for new location
 here that is unique so you don't overlay all the directories into the
 same path and lose everything, so maybe test it with a copy first.  You'll
 also want to check /tmp/grep.errs for any error messages.  I hope this
 helps.

 mark

 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is believed to be clean.

 ___
 gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 find if you
manage to move a directory which is a component of the path it's
currently trasversing.

-- Ben
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 --target-directory option to
mv(1).  That'll come in handy in the future.  Thanks...

  Hmmm, file names with spaces are likely to foul things; xargs splits
on any whitespace by default.  Maybe:

grep --recursive --files-with-matches $searchstring $topdir \
| xargs --delimiter=\\n --max-args=1 dirname \
| sort --unique \
| xargs --delimiter=\\n mv --target-directory=$newloc

  Explicitly specifying the delimiter as newline means newline only.
 Whitespace within a line is ignored.

  (It will still fail if a file name contains a *newline*, but that's
pathological, while file names with spaces are quite common.)

 Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.

  Okay, I'll ask: What does that stuff to the right mean?  Some kind of LISP?

-- Ben

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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, and do something like this:

cat $i/* | grep -l moe  mv $i /destpath || echo mv didn't work: $?

-Ken

On Thu, October 29, 2009 4:41 pm, Ben Scott wrote:
 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 find if you manage to
 move a directory which is a component of the path it's currently
 trasversing.

 -- Ben
 ___
 gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is believed to be clean.





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 D'Ambrosio wrote:
 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, and do something like this:


 cat $i/* | grep -l moe  mv $i /destpath || echo mv didn't work:
 $?


 -Ken


 On Thu, October 29, 2009 4:41 pm, Ben Scott wrote:

 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 find if you manage
 to move a directory which is a component of the path it's currently
 trasversing.

 -- Ben
 ___
 gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/



 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is believed to be clean.





 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is believed to be clean.

 ___
 gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 in your head?

I used to store my good one-liners in Konsole as 'bookmarks' because
you could put anything into a bookmark. Until KDE4. They improved
the bookmark system which now only knows telnet:// and ssh:// URLs.
Konsole even re-writes your bookmarks as you save them by url-encoding
them.  The issue is apparently due to reliance on Kurl - a core class
in KDE, and so not a problem with Konsole.

http://bugs.kde.org/show_bug.cgi?id=185962
http://bugs.kde.org/show_bug.cgi?id=88867

Greg Rundlett

nbpt 978-225-8302
m. 978-764-4424
-skype/aim/irc/twitter freephile
http://profiles.aim.com/freephile
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


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 lucidly: a combinator. ;)

It's a pun. Actually, somehow this never occurred to me before, but
since the sentence as a whole is `an imperative', and the `question'
to be asked is functional, I guess it's... a functional imperative? So
maybe it's a deeper (or worse) joke than I originally intended

 Some kind of LISP?

Almost. Did you have any luck googling for it? :)

-- 
Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/