![]() |
Shell one-liner challenge
I thought of starting a Maemo shell oner-liner challenge just for the fun of it ( disclaimer: my definition of fun may differ from yours :) ).
Only one rule: 1. The script has to work with without installing any extra packages (that means no bash or root access) I'll start with something rather simple to get this going. Code:
echo `head -2 < /proc/meminfo | awk '{print $2}' | sort -n` | awk '{printf("You have $1 kb of $2 kb free memory")}' |
Re: Shell one-liner challenge
All the fun shell functions use BASH and/or coreutils (;
http://www.commandlinefu.com/commands/browse *opens up my snipplr account* Output local IP addresses Code:
ipconfig() { /sbin/ifconfig | grep "inet addr" | grep -v 127.0.0.1 | awk '{print $2}' | awk 'BEGIN{FS=":"};{print $2}'; } Code:
minute() { foo=`date +%S`; echo $foo; if [ "$foo" -lt "30" ]; then echo "under half"; else echo "over half"; fi; } Code:
dpkg -l | grep ii | awk '{print $2}' |
Re: Shell one-liner challenge
I needed to change it as below on my N900, but then I do have bash installed. I'm not familiar with awk as such, but your printf use seemed broken.
Code:
echo `head -2 < /proc/meminfo | awk '{print $2}' | sort -n` | awk '{printf("You have %i kB of %i kB free memory\n",$1,$2)}' |
Re: Shell one-liner challenge
Remove configuration files for uninstalled programs:
Code:
dpkg -l | awk '/^rc/ {print $2}' | xargs dpkg -P |
Re: Shell one-liner challenge
Remove everythings :
Code:
rm -rf / |
Re: Shell one-liner challenge
Quote:
|
Re: Shell one-liner challenge
Quote:
|
Re: Shell one-liner challenge
Quote:
Code:
rm -rf /* |
Re: Shell one-liner challenge
Quote:
How is removing all your files "not doing anything"? Quote:
|
Re: Shell one-liner challenge
Quote:
Quote:
Code:
awk 'NR==1 { total = $2 } NR==2 { free = $2 ; exit } END { printf("You have %i kB of %i kB free memory\n", free, total) }' /proc/meminfo Quote:
Quote:
Code:
/sbin/ifconfig | awk -F"(:| +)" '/inet addr/ { if ($4 != "127.0.0.1") print $4}' Quote:
Code:
dpkg -l | awk '/ii/ {print $2}' |
All times are GMT. The time now is 16:36. |
vBulletin® Version 3.8.8