Saturday, October 29, 2005

Making a list of directories with perl...


perl -e 'for(1..12){my $dir=sprintf("%02i ",$_);mkdir"2005/$dir"}'

Thursday, October 20, 2005

vi move line

<ESC>:11m32<Enter>

will move line 11 to 32. :o)

(works in standard vi too)

<ESC>:11,15m32<Enter>

works too...

*just* found it by accident after all these years!
(thanks vim command history so I could see what I typed instead of 11,32!!!)

Thursday, October 13, 2005

NIS commands


$ nisgrep username passwd.org_dir
username:ENCRYPTPASSWD:1000305537:10:User Name:/home/username:/bin/ksh:13063:1:63:14:::

$ getent passwd username
username:x:1000305537:10:User Name:/home/username:/bin/ksh

$ niscat -o '[name=username]passwd.org_dir'
Object Name : "passwd"
Directory : "org_dir.domain.com."
Owner : "username.domain.com."
Group : ""
Access Rights : ----r-----------
Time to Live : 12:0:0
Creation Time : Wed Aug 3 13:10:33 2005
Mod. Time : Fri Oct 7 10:39:27 2005
Object Type : ENTRY
Entry data of type passwd_tbl
[0] - [8 bytes] 'username'
[1] - [14 bytes] Encrypted data
[2] - [11 bytes] 'XXXXXXXXX'
[3] - [3 bytes] '10'
[4] - [14 bytes] 'User Name'
[5] - [14 bytes] '/home/username'
[6] - [9 bytes] '/bin/ksh'
[7] - [17 bytes] Encrypted data

$ ypmatch USER passwd

Perl inline edit...

http://www.rice.edu/web/perl-edit.html

autovivification

exists => nasty...

if ( $HASH{'key1'}{'key2'} );

Will define $HASH{'key1'}

If you don't want to do that you need to do:

if ( $HASH{'key1'} && $HASH{'key1'}{'key2'} );