Little bash programming

Robert Bushman plug-discuss@lists.plug.phoenix.az.us
Thu, 11 Jul 2002 00:21:40 -0400 (EDT)


Another fun one - kill all instances of Mozilla
(or whatever you put in the grep token):

kill `ps -a | grep mozilla | awk {'print $1'}`

On Wed, 10 Jul 2002, Kevin Brown wrote:

> hmm, command-line quickies?
>
> "cd -" : takes you to the last directory you were in.  Good way to bounce
> between two directories in far areas of the filesystem.
> "cd ~" or "cd" : takes you to your home directory.
> "rpm -qa | grep <text>" : find a package if it was installed.
> "tail -f <file>" : watch a file as it changes.  Can't think of a way to do this
> in Windows and notepad can't deal with large text logs.  Would hate to think
> what would happen opening the logs in Word.
>
> can't think of any other quicky command-line tricks, but most commonly used unix
> commands for me are (in no particular order): cd, ls, grep, rpm, sed, awk, vi,
> man, and tail.
>
> Anyone want to expand on this?
>
> > How about chipping in on a presentation then?
> > We'll put someone more foolhardy in front of
> > the slings and arrows :) (I'll do it if noone
> > else is interested)
> >
> > Maybe list your 10 favorite CLI quickies?
> > (everyone is more than welcome to contribute!)
> >
> > Business for Engineers - it's the same damned
> > thing at U Cincinnati. ugh. The instructor had
> > the worst toupee I've ever seen - it was jet
> > black, but his hair was gray.
> >
> > On Tue, 9 Jul 2002, Kevin Brown wrote:
> >
> > > EEEAAAKKKK!!!!, Public speaking.
> > >
> > > Something that still gives me nightmares.  Was one of the reasons I did so poor
> > > in the "Business for Engineers" classes at ASU where all they did was teach
> > > Excel and giving presentations.
> > >
> > > > Nice! To me, bash and the GNU tools are at
> > > > least 50% of why I can't be as productive
> > > > on MS. This is the sort of thing that makes
> > > > advanced Windows users go, "oooh, that's
> > > > pretty cool."
> > > >
> > > > Wanna do a presentation or demo of CLI-power
> > > > at Install Fest?
> > > >
> > > > my favorite quickie for new users:
> > > >
> > > > $ apropos file
> > > >     (too many results)
> > > > $ apropos file | grep -i compress
> > > >     (ahh, that's better)
> > > >
> > > > Let's see you try that on Windows :)
> > > >
> > > > On Tue, 9 Jul 2002, Kevin Brown wrote:
> > > >
> > > > > Came home tonite and got onto my Workstation and noticed that my IceWM session
> > > > > from the server was gone.  Sometimes it disappears because the two boxes lose
> > > > > contact with each other.  So I logged into the box and exported the DISPLAY
> > > > > varaiable and restarted IceWM.  Then it occured to me that I could make this
> > > > > much easier for myself.
> > > > >
> > > > > Played around with ps, grep, and awk and got something that would find the users
> > > > > who have icewm running.  X is never run directly on the box because the only
> > > > > time I sit at it is if it goes down.  So, I decided to muck with my
> > > > > .bash_profile and see if I could auto fire off icewm from me just logging in.
> > > > > Short story made shorter, yep.  Only a little basic thing, but since I rarely do
> > > > > any coding (shell or otherwise) I think it was pretty good.  Great thing is, it
> > > > > will only fire up icewm if I don't already have a copy up.
> > > > >
> > > > > username=`ps -ef | grep <username>.*[0-9].icewm | awk '{print $1}'`
> > > > >
> > > > > if [ ! Xhellgate = X$username ]
> > > > > then
> > > > >         echo "IceWM not running on your display"
> > > > >         export DISPLAY=<my ip>:0.0
> > > > >         icewm &
> > > > > fi
> > > > >
> > > > > Guess I can later try and add some more sanity checking, but this works for now
> > > > > :)
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list  -  PLUG-discuss@lists.plug.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>

--------------------------------------------------------------------
 "We need commonsense judges who understand that our rights were
 derived from God. Those are the kind of judges I intend to put on
 the bench." President George W. Bush, 27 June 2002
 http://www.nando.net/politics/story/453192p-3627921c.html

 "no religious Test shall ever be required" Constitution Article 6
 http://www.law.emory.edu/FEDERAL/usconst/art-6.html
--------------------------------------------------------------------