Posterous theme by Cory Watilo

Filed under: linux

És ha 10 millió majom használna AWK-t?

Cross posted from Proggit. Though they don't show self-posts there, so it is good as dead. Copy and paste to terminal and enjoy!

awk 'function wl() {rate=4000; return int((rate/160)*(0.87055^(int(rand()*10))))}; BEGIN {srand(); wla=wl(); while(1) {wlb=wla; wla=wl(); if (wla==wlb) wla*=2; d=(int(rand()*10+5)*rate/4); a=0; b=0; c=128; ca=40/wla; cb=20/wlb; de=rate/10; di=0; for (i=0;i<d;i++) {a++; b++; di++; c+=ca; c+=cb; if (a>wla) {a=0; ca*=-1}; if (b>wlb) {b=0; cb*=-1}; if (di>de) {di=0; ca*=0.9; cb*=0.9}; printf("%c",c)}; c=int(c); while(c!=128) {c<128?c+=1:c-=1; printf("%c",c)};};}' > /dev/dsp

If you run OSSv4, use rate=64000 Someone with a better sense of pitch might want to find rate numbers that are more in tune. If it stutters on your computer (though you'd need to have a Pentium 2 for this to happen) use mawk instead.

It uses a pentatonal scale, so it'll probably sound slightly out of tune no matter what you do.

It is also my first awk script, go easy on me. Improvements welcome.

Edit: formatted for your viewing pleasure.

awk 'function wl() {\
        rate=4000; \
        return int((rate/160)*(0.87055^(int(rand()*10))))}; \
    BEGIN {\
        srand(); \
        wla=wl(); \
        while(1) {\
            wlb=wla; \
            wla=wl(); \
            if (wla==wlb) \
                wla*=2; \
            d=(int(rand()*10+5)*rate/4); \
            a=0; b=0; c=128; \
            ca=40/wla; cb=20/wlb; \
            de=rate/10; di=0; \
        for (i=0;i<d;i++) {\
            a++; b++; di++; c+=ca; c+=cb; \
            if (a>wla) \
                {a=0; ca*=-1}; \
            if (b>wlb) \
                {b=0; cb*=-1}; \
            if (di>de) \
                {di=0; ca*=0.9; cb*=0.9}; \
            printf("%c",c)}; \
        c=int(c); \
        while(c!=128) {\
            c<128?c+=1:c-=1; \
            printf("%c",c)};};}' > /dev/dsp

Any idea?

up vote 3 down vote favorite
2

Today I found something really interesting (at least to me) on one of our test servers:

I can change into an existing directory from my actual working directory using a relative path, but that very same directory is not listed when using ls -a.

Here is the shell session (as root):

$ pwd
/you/are/here
$ ls -a
. ..                       <-- Note: "somedir" is not shown to root
$ echo $CDPATH

$ cd somedir               <-- But still: "cd" works fine
$ pwd
/you/are/here/somedir
$ cd ..
$ pwd
/you/are/here
$ ls -a
. ..

Could someone tell me, how is this possible at all? I have checked: ls is from /bin/ls, and pwd is /bin/pwd, both from their original package (I mean: not hacked).

/you is a mounted EMC disk (ext3). And somedir exists as I can list the contents of it (there are several subdirs, files). Its name does not start with a dot.

Some more shell session, with more info about the commands and the ls output:

root@U-TEST@AT$/bin/ls -ali
total 4
16515074 drwxrwxr-x  2 U8000966 test 2048 Sep  1 07:39 .
16515073 drwxrwxr-x  3 U8000966 test 2048 Apr 27  2006 ..
root@U-TEST@AT$ls -ali somewhere | head -5
total 182
16515075 drwxrwxr-x  43 U8000966 test  2048 Sep  1 07:39 .
16515074 drwxrwxr-x   2 U8000966 test  2048 Sep  1 07:39 ..
16519169 drwxrwxrwx   4 U8000966 test  2048 Jul 25  2007 AAA
16515124 drwxrwxr-x   3 U8000966 test  2048 May 12  2006 BBB
root@U-TEST@AT$type ls
ls is aliased to `/bin/ls $LS_OPTIONS'
root@U-TEST@AT$type pwd
pwd is a shell builtin
root@U-TEST@AT$/bin/pwd
/you/are/here
root@U-TEST@AT$cd somewhere
root@U-TEST@AT$/bin/pwd
/you/are/here/somewhere
root@U-TEST@AT$type cd
cd is a shell builtin

Please note the Total 4 after the first ls -ali. (I don't know if it's relevant...)

Some more tests:

root@UR-TEST@AT$ls
.  ..
root@U-TEST@AT$touch somewhere/testfile
root@U-TEST@AT$ls
.  ..
root@U-TEST@AT$cp somewhere/testfile ./
root@U-TEST@AT$ls
.  ..  testfile
root@U-TEST@AT$du .
2       .
root@URBIS-TEST@AT$

And EMC is: http://www.emc.com/products/family/disk-library-family.htm , but they are only a disk provider in this case, with hard disks, formatted as ext3.

UPDATE

(Sorry, but yesterday I had to leave)

I did check echo *, and its output is: . ... Here are the LS_OPTIONS: -a -N --color=tty -T 0.

I had checked the automount thing mentioned by Gilles, but as I had changed to somewhere and issued a mount|grep somewhere there were no output.

link|edit|delete|flag

LOLBASH

# LOL!!1

alias wtf='dmesg'
alias onoz='cat /var/log/errors.log'
alias rtfm='man'

alias visible='echo'
alias invisible='cat'
alias moar='more'

alias icanhas='mkdir'
alias donotwant='rm'
alias dowant='cp'
alias gtfo='mv'

alias hai='cd'
alias plz='pwd'

alias inur='locate'

alias nomz='ps -aux'
alias nomnom='killall'

alias cya='reboot'
alias kthxbai='halt'