iDevGames Forums
Terminal/bash one liners - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Community Zone (/forum-4.html)
+--- Forum: Assembly Room (/forum-13.html)
+--- Thread: Terminal/bash one liners (/thread-3361.html)



Terminal/bash one liners - unknown - Apr 11, 2007 12:32 AM

Ok heres some so you know what im talking about:

Code:
# run this and then open the file system_graphics.html
sudo find /System -name "*.png" | sed -e 's/\(.*\)/<img src="file:\/\/\1"><\/img>/' > system_graphics.html && open system_graphics.html

Code:
# convert all the pngs in the folder to jpegs
for i in *png ; do sips -s format jpeg "$i" -o "`echo $i | sed -e 's/\(.*\)png/\1jpg/' | sed -e 's/\(.*\)/\1/'`" ; done

Code:
# open whats on the dock
defaults read com.apple.dock | sed -n -e 's/.*"_CFURLString" = "\(.*\)\/.*/open \"\1\"/p' | sh

OK, so what one liners do you know?


Terminal/bash one liners - OneSadCookie - Apr 11, 2007 02:06 AM

The standard one:

Code:
.(){ .|.&};.



Terminal/bash one liners - milkfilk - Apr 11, 2007 09:31 AM

OSD gives us a fork bomb. Eesh. I wonder if that actually does anything, I don't really have the brain-space to maintain which Linux/BSD/etc default installs allow the right ulimits (or whatever) that let the fork bomb work. I'll google it later.

Just don't run that or you'll be a sad cookie too! Rasp

Top 10 directories in size (GNU)
Code:
du -sc /|sort -rg|grep -v total|head -n 10

Don't have a mac to test it with.

Top 10 directories in size (Solaris)
Code:
du /* | sort -rn | head -n 10


Doing something until it works:
Code:
CD=1; while [ ! $CD -eq 0 ] ; do cd /tmp/fake; CD=$?; sleep 5; done

Then in another terminal, do `md /tmp/fake'. Loop exits. I used it for a shell tool that would update itself in a connectionless way, ie: it would time-out or bomb and I'd run the command again until it completed successfully.

I'd suggest something along the lines of development but if you wanted to build constantly (continuous integration) then cruisecontrol or what-not is obviously better than a stupid shell script loop.


Terminal/bash one liners - kelvin - Apr 12, 2007 12:50 PM

Can't think of anything too nifty off the top of my head...
I think this is useful though:

mirror/backup my itunes library to my iMac from my MacbookPro
Code:
rsync -av Music kelvin@tantrum.local:/Users/kelvin
works with Pictures too for my iPhoto lib.


Terminal/bash one liners - Duane - Apr 12, 2007 05:15 PM

hm, did someone delete my post?
either that, or I was more tired that I thought....


Terminal/bash one liners - igame3d - Apr 12, 2007 05:52 PM

Nayr Wrote:hm, did someone delete my post?
either that, or I was more tired that I thought....

Hmm I received a notification in email of an update to a different thread,
but when I arrived the post in my email did not exist on the forum, bugs?


Terminal/bash one liners - Shunter - Apr 12, 2007 06:25 PM

My favorite:

Code:
exit



Terminal/bash one liners - unknown - Apr 12, 2007 06:26 PM

Nayr Wrote:hm, did someone delete my post?
either that, or I was more tired that I thought....

repost if you had somthing interesting


Terminal/bash one liners - Duane - Apr 12, 2007 06:36 PM

ok, here it is: a quick line of bash I stole from a screensaver for a super-fast BRUTAL logout:
Code:
kill -15 `ps ax | grep -i loginwindow | grep -v grep | cut -c 1-6`

[edit1]oh yea, on debian gnu/*: apt-get moo[/edit1]


Terminal/bash one liners - Joseph Duchesne - Apr 13, 2007 11:58 AM

Can't remember where I got this, but it's not mine:

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &

This runs the screensaver as a desktop image. Looks really cool with this screensaver
(note: remove the & if you don't want this to run in the background)
(note2: kill it by actually turning on the screensaver)

I wrote a little control panel hinging on this and:
defaults -currentHost write com.apple.screensaver modulePath \"%s\"
defaults -currentHost read com.apple.screensaver modulePath
but I never bothered putting online because there are a bunch of free control panels that do just this but better (sleep doesn't kill it).


Terminal/bash one liners - unknown - Apr 19, 2007 01:48 AM

Set the terminal to green text on on black backround & enter the matrix Rasp

Code:
while true ; do dd if=/dev/urandom bs=1200 count=1 2>/dev/null | md5 ; done | sed`echo '0ヰ1東2京3ス4ス5オ6ラ7カ8ス9ケaトbダcガd㒵eジfヤ' | sed -e 's/\(.\)\(...\)/ -e s\/\1\/\2\/g/g'`

edit: It can be written a lot shorter than I had it before Grin