View Single Post
Old 5th March 2005, 00:01   #326
Forum King
xzxzzx's Avatar
Join Date: Aug 2002
Posts: 7,254
Originally posted by Phily Baby
I can see GUIs doing just that kind of thing very well. You just have to create a workflow program that groups all programs into categories such as text editing, graphics etc. You drag and drop programs onto the workbench, connect up flow lines, add some filters and conditional logic and you're done.
This is the kind of thought I was trying to stimulate.

Still, while my example may be artificial, it is an example that could be far more easily accomplished with a text interface. Regexes are my best friends. Recently, I had to handle a mail server that was misconfigured and acting as an open relay - I decided that I'd get rid of the email that was in the outgoing queue that had come from the relatively few other servers on the net that had discovered this one.

It was easily done with a find command:

find /var/qmail/queue/mess/ -exec grep "^Received:.*(spammer's ip)" {} \;
-print -exec ~/ \;

I'm sure there are GUI-based tools available that would perform something like this, but I doubt there are any that would easily allow me to tweak my command. For example:

find /var/qmail/queue/mess/ -exec grep "^Received:.*(spammer's ip)" {} \; -or
-exec grep "^Subject: WANT A BIG PEN[I1]S. CL[I1]CK HERE" {} \;
-print -exec ~/ \;


While I understand your point about cryptic commands, Phily, you should see a competent Unix administrator who's been using those commands for a while. It's fucking magic.

Plus, it looks really good to your boss who has no idea what those strange things on your screen are, and is amazed at your fingers flying over the keyboard and your comprehension speed as you use auto-complete and are only reading the one relevant piece of data from a list of 50 .

Efficiency brings on a whole new meaning. Want the PID/image name for the program that's listening on port 80?

legolas root # netstat -tlnp | grep ":80"
tcp 0 0* LISTEN 2661/apache2

How many lines of code are in my project's .txt files, anyway?
legolas source # find -name "*.txt" -print0 | xargs -0 cat | wc -l

Hmm, that seems high. What if I don't count blank lines?

legolas source # find -name "*.txt" -print0 | \
xargs -0 cat | grep --invert-match "^ *$" | wc -l

That's better. By the way, if the file names didn't include spaces or wierd symbols (like a file named "bl*ah.txt"), the commands would be more like:

find -name "*.txt" | xargs cat | wc -l

and if you didn't have too many .txt files to overwhelm your shell (253?), you could do:

wc -l `find -name "*.txt"`

As for:
Originally posted by Phily Baby
And more often than not it is quicker to do it all manually instead of read the help file for one command, try and find out a crypticly named utility that does what you want. Learn to use it, pipe it into something else and, yadda yadda yadda.
You're right, it's often faster the first time, and the second time, and even maybe the third time, but there eventually comes a point where you're less productive than if you'd lost the time learning. And it's not like these commands have exactly precise applications - once you've learnt how to use grep, or find (not to mention sed or awk)...

I used to view unix commands as I believe you do, that they're cryptic commands with limited use, and that it takes huge investments of time before you get any use at all out of them. It's not true, though - learning just a few commands, you have amazing power at your fingertips. It's not a mistake, these commands have been around for a very very long time in the Unix world.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote