Do you know how to use "Terminal"?

Discussion in 'macOS' started by Amerabian, Oct 2, 2011.

?

Do you know how to use "Terminal" ?

  1. Yes, of course!

    52 vote(s)
    74.3%
  2. I'm learning/new to commandline

    10 vote(s)
    14.3%
  3. Nope!

    8 vote(s)
    11.4%
  4. What the heck is Terminal?!!

    0 vote(s)
    0.0%
  1. Amerabian macrumors regular

    Joined:
    Apr 25, 2011
    #1
    I'm just curious to know how many Mac users actually know how to use command-line to perform.. well, just about everything -through "Terminal"

    I was just porting some unix stuff to my machine and the experience just assured me that I've chosen to move to Mac OS for very good reasons :apple:

    So, how many of us Mac users actually use Terminal?

    :D
     
  2. AlanShutko macrumors 6502a

    Joined:
    Jun 2, 2008
    #2
    I ran Linux as my desktop OS from 1994 to 2008, so I'm well used to doing things in the terminal. I still use Emacs and pop into the terminal to script or do something several times a day.
     
  3. bobotech macrumors newbie

    Joined:
    Sep 29, 2011
    #3
    The terminal is one of the reasons why I have grown so fond of Mac OS X over the years.
     
  4. fivenotrump macrumors 6502

    Joined:
    Apr 15, 2009
    Location:
    Central England
    #4
    The fact that Mac OS X is based on BSD is what made me first take it seriously as an operating system. The Terminal is the essential 'window' on the system: unfiltered by GUIs, which while often useful, sometimes obscure the essentials.
     
  5. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #5
    What you use terminal for?

    What do you actually use it for. Could someone give us several practical examples they have done lately in terminal that could not be performed in any other application :eek:?
     
  6. AlanShutko macrumors 6502a

    Joined:
    Jun 2, 2008
    #6
    I wouldn't say that I use it for things that can't be performed in other applications, but it makes things easier. For example, I'd downloaded a couple thousand zip files. find . -name "*.zip" -exec uz '{}' \; (where uz is another script which will make a directory for the contents if the zip file doesn't have a single directory) was a whole lot easier than selecting them all in the finder and opening them.

    I have other scripts which I've attached to Hazel actions to rename files for me. When I download a statement from my bank, utility, or something like that, Hazel will trigger the script, which will extract the statement date from the text of the PDF and rename the document accordingly.

    Some things are just quick one-offs, like doing a grep over some plists to see which is the one I need to worry about or using rsync to move a directory from one place to another (much faster than an AFP copy).
     
  7. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #7
    Wow thanks Alan, sounds pretty impressive and the exact reason why computers were invented.
    Similar to automator but I imagine that you can create and do anything as you wish; except with automator you're limited.
    Thanks for your examples.
     
  8. Gregg2 macrumors 603

    Joined:
    May 22, 2008
    Location:
    Milwaukee, WI
    #8
    Know how? Well, yeah. Know what to type? Nope.
     
  9. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #9
    Where could one learn scripting? There must be a website with lots of downloadable scripts for everything.
    Alan; great example with your bank statements. Every year I need to analyse each transaction and list them seperately - e.g. 'direct-debits' and 'cash-withdrawals'.
    Would it take me long to figure out how to do this cunningly with the computer; bearing in mind its about three days to do manually. Significant savings could be made :). Where could I find how to do it?
    Regards
     
  10. Dr. McKay macrumors 6502a

    Joined:
    Jan 20, 2010
    Location:
    Belgium, Europe
    #10
    Actually, I'm looking for a good book that'll teach me about the command line and OS X in general.
    OS X Bible or David pogue's missing manual perhaps ?
     
  11. Phil A. Moderator

    Phil A.

    Staff Member

    Joined:
    Apr 2, 2006
    Location:
    Shropshire, UK
    #11
    Same here - I've been using Unix systems for over 20 years and it was the main reason I moved to Macs: Before OS X, I wasn't interested in them but once OS X came out, I moved to a Mac and haven't looked back since :)
     
  12. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #12
    I don't think David Pogue's book would be much help in that regard. It is more aimed at novice users and teaching them the bash shell in a Missing Manual book flies in the face of the assertion that OS X "just works." It would be the equivalent of a Windows basics book that started delving into cmd or the registry.

    I tend to like the O'Reilly books "In a Nutshell" series. There is one called "Learning the Bash Shell" that costs $16 for the Kindle edition (which you can read on your Mac) or $21 for the book. Barnes & Noble also sells it for $21 and their web site says it is available for pick up in store.
     
  13. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #13
    Thanks for recommending book. I bought one recently on apple scripting; I wonder if much is similar in terminal?
    What computers have unix / linux etc. I hear experts on this forum talk about them and I have only done brief research just now. Seems like old-school computers?
     
  14. old-wiz macrumors G3

    Joined:
    Mar 26, 2008
    Location:
    West Suburban Boston Ma
    #14
    Old-School???? You would be surprised how many current enterprise level systems run on *NIX. There are huge numbers of systems that run on *NIX. Our local library system supports 28 libraries from Unix servers. When you move beyond personal computers to business levels, you frequently find *NIX servers running there.
     
  15. AlanShutko macrumors 6502a

    Joined:
    Jun 2, 2008
    #15
    Applescript and shell scripting (ie, Terminal) have some things in common, but there's a lot different.

    Applescript is all about getting the GUI applications that you use to run actions. Most Mac apps have some level of applescript support, so for instance you can write a script that gets Photoshop to do something. Or, even better, you can get multiple applications to talk to each other. For instance, my wife photocopies checks before she deposits them and I later scan them. I have a script that allows me to select the PDF, and then it opens it in Photoshop and tries to automatically straighten and crop it just to the check. If that doesn't work, it opens it up in PDFPen and selects the crop tool for me to crop things manually.

    Shell scripting is a bit older and different. In the terminal, there are a lot of commands that can be strung together to do different things. Generally, they are a separate set of commands from your GUI apps, and each only has a tightly focused piece of functionality. You string them together by the way that most of them accept text input and put out text output.

    Both are useful for different things, and you can also use them together.

    To learn old-school Unix scripting, a good book I've read for understanding the types of things that can be done is Unix Power Tools. It gives you lots of small recipes for how to do different things.
     
  16. Dr. McKay macrumors 6502a

    Joined:
    Jan 20, 2010
    Location:
    Belgium, Europe
  17. bobotech macrumors newbie

    Joined:
    Sep 29, 2011
    #17
    Here is a good example of why I like Terminal. I can ssh into a remote computer, scp (secure copy) an installer file to that machine, then use the installer command to execute that command and the installer will install silently with or without the user logged on and they will never know that the package got installed.
     
  18. George Jetson macrumors newbie

    Joined:
    Nov 21, 2010
    #18
    I Use Terminal For....

    Here are 2 things that I routinely need Terminal for:

    1). Before I do a system backup, I like to remove the hundreds and hundreds of megabytes of swapfiles. I don't know why they get created since I have 8GB of RAM and seldom use more than 5GB, but I don't like backing up all that junk.

    2). There have been a number of times that my security software will quarantine dangerous files into a new folder owned by root, and I can not delete them using the security software or Finder. Using Terminal and superuser makes that a snap.

    Having come from a SUN UNIX world, I use it for many other things as well, but that is just my preference. UNIX is pretty powerful, and I am thankful that Apple makes the transition so easy.
     
  19. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #19
    Thanks, how hard would it be to get a script to open a pdf of a bank statement. Select all debit card transactions and import them into a spreadsheet numbering the transactions of a certain type.


    ≤Debit Card transaction> / outgoing / £50.00 on <materials>

    ≤Debit Card≥ and ≤materials> are categories of a database/ list in excel. I imagine this would be pretty hard and maybe I'll just have to accept manually entering this info manually.:(
     
  20. AlanShutko macrumors 6502a

    Joined:
    Jun 2, 2008
    #20
    That's not easy, but not impossible.

    The first thing you need to do is get the text out of the PDF. I use ps2ascii, which comes with ghostscript. Then, you need to figure out how to get the text you want out of the large amount of text that's in there. Languages like perl, ruby or even awk would help here.

    Probably, it would be easier if your bank offered some other file format. My bank lets me download the data in QIF format (for quicken and other programs) as well as comma separated or Excel formats. That can save you the trouble of having to parse the PDF text.
     
  21. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #21
    Thanks Alan, I know a little xhtml, php but perl and ruby are out of my league and I don't really have time to learn it unfortunately.
    I will contact my bank and see if they can send me different formats. I'm not too optimistic as I don't think their service is too great.
    Some very clever people on here :eek:.
     
  22. ender land macrumors 6502a

    Joined:
    Oct 26, 2010
    #22
    I've run this a few times in the past hours -

    qmake -spec macx-xcode MyProjectName.pro

    I typically have been running this with a python script though :p So I kinda did not really "use" terminal per se ;)
     
  23. stev3n macrumors 6502

    Joined:
    Feb 9, 2010
    #23
    I have used Terminal a bunch but I only know certain commands. My friends used to tell me to type "rm -rf". No one should ever type that into terminal. Luckily, I knew what that did so I never used that command.
     
  24. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #24
    Why what's up with the rm -rf command; that removes something properly; does it not?
     
  25. Mal macrumors 603

    Mal

    Joined:
    Jan 6, 2002
    Location:
    Orlando
    #25
    It's a powerful command, there's nothing inherently bad, but you need to understand it in order to use it safely. If, for instance, you run the command "rm -rf /", then you will have quickly deleted everything at the root of your drive (up until it deletes something that prevents it from continuing), wiping your drive and causing significant amounts of frustration, if not permanently lost data (depending on the presence of backups and/or recovery tools available).

    I did that once, btw, because I was typing in the command and reached for the shift key to start typing Macintosh\ HD, but instead my finger slipped up and hit the return key instead of shift. I watched in horror as the drive, before I could stop it, was completely erased. Fortunately, the OS had just been installed and there was no data on the drive, but it could have been a disaster.

    jW
     

Share This Page