[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Resolution & recovery: Re: Slow disk - hdparm, S.M.A.R.T, badblocks, what else?



on Sun, Jul 11, 2004 at 12:03:10AM -0700, Brian Nelson (pyro@debian.org) wrote:
> "Jacob S." <stormspotter@6texans.net> writes:
> 
> > On Sat, 10 Jul 2004 20:03:32 -0500
> > "Jacob S." <stormspotter@6texans.net> wrote:
> >
> >> On Sat, 10 Jul 2004 17:41:58 -0700
> >> "Karsten M. Self" <kmself@ix.netcom.com> wrote:
> >> 
> >> <snip>
> >> >   - The 'Knoppix' hostname worked its way into a few config files.
> >> >   
> >> >       # find /etc -type f -print0 | xargs -0 grep -il knoppix
> >> > 
> >> >     ...and clean those up.
> >> 
> >> One question, in hopes that I can learn something; what does the above
> >> command gain you that "grep -ril knoppix" wouldn't?
> >                          ^^^^^^^^^^^^^^^^^
> > Oops. That was supposed to be "grep -ril knoppix /etc".
> 
> The 'find' command above only works on regular files (not symlinks),
> whereas 'grep -r' will follow symlinks (and thus could produce
> duplicates or get into recursive loops).

A few other things.

I'll occasionally toss out a really long shell "one-liner" consisting of
several commands, often looped, and/or with if/then processing and
branching.

If you look at that and think "how did he write that all in one go",
it's daunting.  The answer, of course, is that I didn't.

Instead, I build up the command, usually from the inside, and often with
an initial 'find' or 'grep'.

You can use the shell's editing functions (I prefer readline, though
vi mode can also be cool, particularly as you can then invoke an editor
on those one-liners which really _have_ gotten away from you.

Generally, though, C-R (recursive reverse search), C-A (start of line),
and C-E (end of line), as well as character navigation, are what work.

Generally, I'll start with a find, then grep, then wrap that in a "$()"
command expansion, then operate on that.  Sometimes I'll recall and
slightly modify the same basic command for weeks from the command line
before finally committing it to its own shell script.

You do sometimes end up with silly stuff such as:

   ps aux | grep 'pattern' | awk  '{print $2}'

...where:

   ps aux | awk '/pattern/ {print $2}'


...is more appropriate.  But the 'grep' => 'awk' path is more natural
(IMO) than the "well, I'm going to be using awk anyway, might as well
start now.  And the few extra cycles consumed in typical use really
isn't an efficiency concern.


...but that's just me.


Peace.


-- 
Karsten M. Self <kmself@ix.netcom.com>        http://kmself.home.netcom.com/
 What Part of "Gestalt" don't you understand?
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?

Attachment: signature.asc
Description: Digital signature


Reply to: