ejes consulting

Techincal Consulting Design and Automation

Posts Tagged ‘programming

More Command Line Magic

leave a comment »

Wow, I was looking around for a way to quickly convert my ls -al listing into octal ‘0774’ permission display. I found a really neat awk script that does just this here:

it’s this:
ls -l | awk ‘{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(“%0o “,k);print}’

to make it permanent, add this to your .profile:
alias l=”ls -la –color | awk ‘{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\” %0o \”,k);print}'”

Written by ejes

February 25, 2011 at 11:11 pm

Posted in Hacking, Programming, Scripts

Tagged with ,

Super Small printf for embedded applications

leave a comment »

So I like to write embedded applications – the challenge provided by a low power low memory system is always an enjoyable one. Nevertheless, occasionally one needs to recreate standard functionality and with these constraints in mind it can be quite a task. Anyway, I was stumbling around and found this tiny printf utility that is both elegant and tiny:


Written by ejes

February 25, 2011 at 12:09 pm

Posted in Uncategorized

Tagged with ,