![]() |
What "intresting" commands/programs can i do in terminal?
well... i've play'd with linux on my X86 and now am starting to play with terminal on OSX,
sofar i'ce come accross ping emacs pico (looks like the old word star :)) and thats about it, apart from the cd, ls and the like i'm looking for things to play with without paying money for a book or program :) and if i happen to lean some cool commands that'll help my unix side all the better :) |
Magic 8 Ball says: Do a search here for fink and you may find the gateway to many hours of UNIXy fun. :)
|
Learn about find. May uses! In my job, I frequently need to find files that have not been used for a certain time frame. This is an example.
find -mtime +183 -daystart -name '*' -printf '%p\t%s\n' Or how about finding large files. This one finds files larger than 15meg find -size +15360k -name '*' -printf '%p\t%s\n' |
Take a good look at grep, cut, head and tail.
|
Check out 'man open'. I've been trying to figure out a comparable command on my Linux box, and haven't been able to do so so far. But the OS 10.2 version of open lets you do all the old stuff from OS 10.1 (launch apps, open docs, etc with specified apps) and now you can connect to websites too. For example, if I want to search for something on google.com and I'm in the Terminal I type
gsearch <mysearch string> and my default browser opens with the results. #! /bin/sh #gsearch, a script to do a google search in your default browser open="/usr/bin/open" echo="/bin/echo" sed="usr/bin/sed" open http://www.google.com/search\?hl=en\&q=$(echo "$*" | sed 's/ /+/') Welcome to OS X. |
When was the last time you played Adventure?
In terminal, type: Code:
emacs -batch -l dunnet |
"top" & "ps ax"....
Two I find very useful are the
"top" command and the "ps ax" command... You can kill a run-away process easily by listing the # of the process in the left-hand column with the "kill" command. Ps displays a header line followed by lines containing information about your processes that have controlling terminals. This information is sorted by controlling terminal, then by process ID. top displays an ongoing sample of system usage statistics. It operates in various modes, but by default shows cpu utilization and memory usage for each process in the system. Just type "man ps" and "man top" to find out more.... |
Quote:
Code:
$ cat goog |
Weird. I just tried the version I posted (the url shouldn't be underlined, though) and it works. I just tried the version you posted, merv, and nothing happened. /bin/sh is /bin/sh, no? Unless something has changed in your version of 10.2.1? Shrug. At any rate, I forgot to mention earlier that I also use open to look up words (eng omphaloskepsis):
% cat eng #!/bin/sh /usr/bin/open http://www.dictionary.com/search\?q="$*" and translate words: %cat spen #!/bin/sh /usr/bin/open http://www.diccionario.com/cgi-bin/esp-engl.php\?query="$*" from English to Spanish: % cat ensp #!/bin/sh /usr/bin/open http://www.diccionario.com/cgi-bin/engl-esp.php\?query="$*" These might actually work on other people's systems (assuming they'd rather not launch Sherlock 3) :D |
¡no me gusta!
hmm. what does it look like if you uncomment the echos and comment out the open?
|
Well, goog works this morning. Either it was too late when I was testing it last night, or some script gremlins have changed something in my system as I slept. I think it was the latter. But I wonder why the version I originally posted didn't work? /bin/echo vs builtin echo? Both 'gsearch fish hats' and 'goog fish hats' now work on my rig.
|
Re: What "intresting" commands/programs can i do in terminal?
Quote:
|
Timan, MervTormel,
Thanks for the scripts. Have you tried an 'open' replacement called 'launch' ? You can install it with Fink, launch doesn't have any dependencies (works with 10.1 + dev tools) and I find it very useful by itself, but is even better when used in scripts. It is essentially an OS X-savvy version of 'file', 'which', and 'open'. It will open applications, open/print documents, launch URLs, show file info (shows info about any item on disk, including its file type, creator, data and resource fork sizes, dates and bundle ID), etc. Code:
152 [Sao @/Users/pm] % launchCheers... |
Hey, launch sounds like a dream come true. Though fink fails compiling it for me. I think I have the April 2002 dev tools (on 10.1.5).
Those google scripts reminds me of "surfraw". Have you tried that one? It brings the cli interface to google, webster, jeeves and lots of more web enabled services. I should be quite easy to add a "use launch" option to the surfraw scripts. Which would enable results to show up in a new tab in Chimera. "surfraw" is in stable so installing it is a breeze: $ sudo apt-get install surfraw |
Quote:
Code:
#! /bin/sh |
osxpez,
I installed surfraw. Wow! Thanks for the tip. To install 'launch' if you are still in 10.1.5, you could always move /Developer to /Dev_2002-04, then reinstall the old December devtools (and the small update) if you have them around. But maybe too much of a hassle. Code:
152 [Sao @/Users/pm] % surfraw --helpCheers... |
osxpez, no, a space after she-bang is fine
TiMan, i forgot to point out the "troubles" i had with your script a) you define variables, like open=/usr/bin/open , but then never reference the variable in the script. open != $open b) your sed lacked the 'g' global replacement switch and only replaced the first space with plus oddly, whenever i test a google thingy, i search for meat+hats |
sao, that little google thingy was something I originally put together after installing 'launch' a few months back. I figured that since open now has some more bells and whistles, the script would be accessible for the folks who hadn't installed fink (yet) ;) I had also heard of surfraw, but it seemed like too much for what I was wanting to do...maybe I'll have to look into it again, though, 'cause it does look pretty cool. merv, thanks for the tip. There I was trying avoid problems by defining the full path of the commands I was using. A simple one liner:
open http://www.google.com/search\?hl=en\&q=$(echo "$*" | sed 's/ /+/g') probably would have worked. Also thanks for pointing out my missing 'g' in sed. I had originally done sed 'y/ /+/', but when I inserted the s instead of y I never added the g. How's that for alphabet soup. Oh, and I figured out why your script (ie my brain) didn't work. I cut and pasted it into something I had stupidly called 'test' and when I did 'test fish hats' (instead of ./test fish hats) test the shell builtin didn't have anything to say about fish hats. But on to the original question, of cool things to do in the Terminal: softwareupdate sw_vers AppleSystemProfiler Last, but not least, here're some cool things that I've found scouring the web (sorry I can't rememer where; I'd love to give the authors credit). Also sorry about the long post. % cat colors #!/bin/bash # # This file echoes a bunch of color codes to the # terminal to demonstrate what's available. Each # line is the color code of one forground color, # out of 17 (default + 16 escapes), followed by a # test use of that color on all nine background # colors (default + 8 escapes). # T='gYw' # The test text echo -e "\n 40m 41m 42m 43m\ 44m 45m 46m 47m"; for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \ '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \ ' 36m' '1;36m' ' 37m' '1;37m'; do FG=${FGs// /} echo -en " $FGs \033[$FG $T " for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do echo -en "$EINS \033[$FG\033[$BG $T \033[0m"; done echo; done echo cat mandelbrot2 #!/bin/zsh # #mandelbrot fractal # ((columns=COLUMNS-1, lines=LINES)) ((colour=0)) for ((b=-1.5;b<=1.5;b+=3.0/lines));do for ((a=-2.0;a<=1;a+=3.0/columns));do for (( p=0.0, q=0.0, i=0 ; p*p+q*q < 4 && i < 32 ; i++));do ((pnew=p*p-q*q+a, q=2*p*q+b, p=pnew)) done ((colour=(i/4)%8)) echo -n "\\e[4${colour}m " done done |
Surfraw working with links is fast_______________!!!! :)
Cheers... |
If you don't have Fink installed, you can download 'launch' source and binary in gzipped tar format (there is no installer) from this link and follow the install instructions in the README file :
http://web.sabi.net/nriley/software/ Cheers... |
another fun one
"banner" is always fun.:)
|
launch is way cool. Thanks for the hint!
I said that I thought it would be quite easy to pactch surfraw to use launch and that way reach Chimera. In fact is isn't even needed to patch it: $ google -browser='launch Chimera' java os x $ britannica -browser='launch Chimera' platypus Make a few aliases for this if you think it's to much typing. (Please share those aliases). |
osxpez,
Thanks for the use. I was using in X11: google -browser=mozilla osx and google -browser=mozilla -search=mac osx And in OSX : google -browser='launch -l' osx (will open your default browser) Tomorrow will try some more and share. Cheers... |
Surfraw
is there any way not to use Lynx with Surfraw. I would like to open either IE or Netscape/Mozilla.
Any ideas? |
I installed 'launch' with Fink and use it together with surfraw to open my default browser, then use different aliases:
Code:
alias wet 'wetandwild singapore -browser='launch''Cheers... |
| All times are GMT -5. The time now is 10:35 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.