[Newark] Next meeting

Khismett Riddle spindleflax at gmail.com
Sat Mar 1 12:41:05 GMT 2008


I wasn't there, but I think Steve suggested the topic of command line tips
but he wasn't there either so who knows what happened.

Piping find through grep is a nice alternative locate, I also like du -a |
awk '{print $2}' | grep name, and since we're already using awk, it's fairly
easy to add quoting by changing the expression to '{print "\""$2"\""}' .

On a similar topic, I found a way to make a very simple chat system for all
those times when you're on a shell server and want to talk to people but
find write too basic. Of course, there's talk but some people don't have it,
especially with some of these new-fangled distros that like to pretend the
terminal isn't there (it's my understanding that the vintage 2006 coreutils
provided in Ubuntu Gutted don't have shuf and the sort doesn't have -R, so
no randomised lists for Ubuntu users). So, someone makes a file called
chatlog that's read-write by the users group and each user runs the
following command whilst browsing the directory that chatlog is in: sed -u
"s/^/$(whoami): /" /dev/stdin >> chatlog | tail -f chatlog

That's pretty much all there is to it, users type messages on stdin and it
appends them to chatlog whilst simultaneously reading the contents of the
file as it updates to catch new messages. The sed expression prefixes each
message with the user's name before it sends it to chatlog so people can
tell who's who. The chatlog, as the name suggests, ends up with a complete
log of the chat for future reference. One can continue the conversation at a
later date because the contents of chatlog will be sent to the terminal
whenever one starts a chat.

Now one can add a few features. For example, appending | grep -v
"$(whoami):" will ignore the you send and only show everyone else's messages
(and what you type on stdin). Changing the sed expression slightly would
allow all kinds of things, timestamps and such. Since you type messages into
the same terminal as you receive them, it messes up if you're typing as
another user sends, that's not really very helpful. It can be fixed by using
another terminal (better yet, using screen to make a small input terminal
and a large output one). The input terminal has sed -u "s/^/$(whoami): /"
/dev/stdin >> chatlog  and the output terminal has tail -f chat. Now you can
type without fear! Also, either side can be changed to a more appropriate
command depending on the setup. For example, a zenity input box could be
used for messages instead of pure stdin.

So there you have it, a one-liner chat system. That's what I would've
bothered y'all with if I'd been at the meeting.

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/newark/attachments/20080301/e9298597/attachment.html


More information about the Newark mailing list