How can I easily run a terminal command?

Discussion in 'macOS' started by lukin, Nov 19, 2008.

  1. lukin macrumors regular

    Joined:
    Jul 24, 2008
    #1
    Hello, thanks for your help.

    I want to run some terminal commands fairly often... yet I don't want to have to type them. I just switched from windows, so I need some help as to how to do this.

    In windows I would've just used a batch file to run command prompt commands. I need something that will let me just run it and it will automatically run the commands.

    Thanks.
     
  2. hayduke macrumors 65816

    hayduke

    Joined:
    Mar 8, 2005
    Location:
    is a state of mind.
    #2
    Simple example. Create a text file named "junk.txt" that contains following:

    #!/bin/bash
    ls -ltr

    Then type:

    chmod 755 junk.txt (makes your file executable)

    Then type:

    ./junk.txt

    And you'll see a list of files in the current directory.
     
  3. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #3
    If you want the file to be double-clickable just use the previous poster's example but call it "junk.command" instead of "junk.txt". The finder will the recognize that it is a script and let the terminal handle it.
     
  4. hayduke macrumors 65816

    hayduke

    Joined:
    Mar 8, 2005
    Location:
    is a state of mind.
    #4
    Hey! I didn't know that one. Excellent.
     

Share This Page