Terminal/bash one liners

Sage
Posts: 1,403
Joined: 2005.07
Post: #1
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?

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
The standard one:

Code:
.(){ .|.&};.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2006.03
Post: #3
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.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #4
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.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #5
hm, did someone delete my post?
either that, or I was more tired that I thought....

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 715
Joined: 2003.04
Post: #6
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?
Quote this message in a reply
Member
Posts: 78
Joined: 2004.06
Post: #7
My favorite:

Code:
exit

When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #8
Nayr Wrote:hm, did someone delete my post?
either that, or I was more tired that I thought....

repost if you had somthing interesting

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #9
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]

It's not magic, it's Ruby.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #10
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).
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #11
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

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPhone’s Very Own Credit Card Terminal michelle2010 0 2,137 Jan 11, 2010 10:59 AM
Last Post: michelle2010
  ^D in terminal causes logout unknown 6 3,959 Jun 20, 2007 01:34 PM
Last Post: Skorche
  Fullscreen Terminal Nick 12 5,883 Aug 30, 2005 07:53 AM
Last Post: Nick
  Terminal use question - how to access directories start from the hard disk Byron Clarke 12 6,666 Aug 29, 2005 07:08 AM
Last Post: Malarkey