[kwlug-disc] my new favourite command

Richard Bettridge rbettridge at rim.com
Mon Dec 6 14:17:21 EST 2010

Just throwing this out there. I find myself often abusing this as it's quick and dirty, but performance wise if you're trying to process a lot of data you'll take a serious hit.

I find this most handy when I'm troubleshooting systems via logs, and I have wound up with seemingly endless pipes. And suddenly I need to throw this all into a loop to act on each line.

Example, after time spent, I end up with something like this(below), now I decide I need to massage the data into a report and would rather not rewrite my commands. In other words I'd rather not redo it from scratch, the proper way, after already getting this far invested. Best used when issuing a lot of hackiness to narrow down an issue.

grep something filename|cut something|awk something|maybe grep something_else;

grep something filename|cut something|awk something|sed '/this/that/'|maybe grep something_else|while read line


#Do some sort of data manipulation per line but for now just print the var

echo $line;

#This can get real handy if I want to perhaps pass the line through an if or case statement and act accordingly

if [ $line = someting]


                  #Do something



Mentioning this incase people might find it handy. I by no way suggest this being a good approach. But it is a lazy approach, "I need to loop through some data now, and I don't want to think about how best to do it, just want it done."

Richard Bettridge

BIS-E SV&V Performance - Waterloo

-----Original Message-----
From: kwlug-disc-bounces at kwlug.org [mailto:kwlug-disc-bounces at kwlug.org] On Behalf Of William Park
Sent: Friday, December 03, 2010 11:45 AM
To: KWLUG discussion
Subject: Re: [kwlug-disc] my new favourite command

On Thu, Dec 02, 2010 at 03:49:20PM -0500, John Van Ostrand wrote:

> ----- Original Message -----

> > Hi list,

> >

> > Just discovered the 'rlwrap' command. It is a wrapper that turns

> > any command line oriented program into a readline-capable interface.

> >

> > For example, you can run netcat through rlwrap, and get history and

> > command editing:

> >

> > rlwrap nc

> >

> > This also works for things like xboard when connecting to a chess

> > server (this is where I first learned of it).

> >

> > What other new commands have people learned lately?


> This is a side question. Is there another way to put readline functionality in a bash shell script?


> e.g.


> while :

> do

>     read cmd


>     case "$cmd" in

>     "load")

>          ...

>     "save")

>          ...

>     esac

> done

Are you thinking something like "select" in Bash/Ksh?  "select" will

give you menu, but I don't think it will go through Readline.




kwlug-disc_kwlug.org mailing list

kwlug-disc_kwlug.org at kwlug.org


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20101206/9fe008ee/attachment.html>

More information about the kwlug-disc mailing list