TEK TIPS

This (rarely updated page because I tend to forget it exists) is a collection of mostly unix-related tips & tricks I've come over on some page, news-message or through irc or some other channel, sometime or other.


Diffing files and directories, showing only unique lines

With zsh:

% comm -12 <(sort fil1) <(sort fil2) 

With es:
comm -12 <{sort fil1} <{sort fil2} 

With Perl:
#!/usr/bin/perl

my %lines=();
my $filename1=shift;
my $filename2=shift;
open (FILE1, "<$filename1");
while (<FILE1>) {
        $lines{$_}=1;
}
close(FILE1);
open (FILE2, "<$filename2");
while (<FILE2>) {
        if (!$lines{$_}) {print;}
}
close(FILE1);


FreeBSD and ISDN

Use the package ISDN4BSD, it's available from ftp.consol.de/pub.

Log in as user isdn4bsd, using your email-address as the password.

Anonymous ftp will not work!


What rootshell to use

It must be statically linked. If you don't feel like testing destiny, use good old sh, which is quite usable after a set -o emacs.


"And the First Shall be the Last": Reversing the lines of a file

Original file:

line1
line2
line3

With the GNU textutils tac:

% tac file
line3
line2
line1

In vi(1) or vim(1):

:%g/^/m0 or :1;$g/^/m0 or :%g//m0

In vi(1) or vim(1) using the GNU textutils tac:

:%!tac or :1,3!tac


Root


copyleft 1998-2004 taliesin
unless otherwise noted