perl -e 'for(1..12){my $dir=sprintf("%02i ",$_);mkdir"2005/$dir"}'
A place for John to record his techy notes, both to refer back to when needed, and as a help for others...
Saturday, October 29, 2005
Making a list of directories with perl...
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!!!)
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!!!)
Wednesday, October 19, 2005
Perl conditional (colon) operator.
printf "I have %d camel%s.\n", $n, $n == 1 ? "" : "s";
http://www.unix.org.ua/orelly/perl/prog3/ch03_16.htm
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
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'} );
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'} );
Thursday, March 10, 2005
PHP error...
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /dirname/filename.php(000) : eval()'d code on line 3
put {} around the $_SERVER['VARIABLE'] like this: ${_SERVER['VARIABLE']}
put {} around the $_SERVER['VARIABLE'] like this: ${_SERVER['VARIABLE']}
Wednesday, March 09, 2005
awk bits...
# List of logins
# List of unique logged in users
who | awk '{name[n++]=$1};END{for(i=1;i<=n;i++){printf name[i]" "}; print ""}'
# List of unique logged in users
who|awk '{w[$1]=$1};END{for(n in w)printf" "n}'
Tuesday, March 08, 2005
10 years and still counting...
Crazy... 10 years at this now, and I'm still learning the basics...
Take a break ... command :o) ...
Never needed it till now... but I was thinking... .o0(I need to break out... what would the command be?)
Or driving sed... instead of:
how about:
:o)
Take a break ... command :o) ...
DATE=$(date +'%y%m%d')
for VER in $(seq -f %02g 99)
do
if [ -f file_${DATE}-${VER}.tar -o -f file_${DATE}-${VER}.tar.gz ]
then
echo "file_${DATE}-${VER}.tar already exists..."
else
tar cvf file_${DATE}-${VER}.tar clean
gzip -9 file_${DATE}-${VER}.tar
break
fi
done
Never needed it till now... but I was thinking... .o0(I need to break out... what would the command be?)
Or driving sed... instead of:
sed 's/^ *//g' | grep .
how about:
sed -n 's/^ *//g;/./p'
:o)
Monday, March 07, 2005
Very cute...
I was wondering last night .oO(has anyone written a text editor in Perl?) - not an x app like ptked, but a console app... and yes of course they have...
http://ped.sourceforge.net/
- one of the monks has even done vi :o)
https://sourceforge.net/projects/vip
http://perlmonks.thepen.com/41736.html
Oh, and... http://ppt.perl.org/commands/ed/index.html
http://ped.sourceforge.net/
- one of the monks has even done vi :o)
https://sourceforge.net/projects/vip
http://perlmonks.thepen.com/41736.html
Oh, and... http://ppt.perl.org/commands/ed/index.html
Subscribe to:
Posts (Atom)