View Poll Results: Do you use a .sh file instead of individual commands into Terminal

Voters
22. You may not vote on this poll
  • Yes

    6 27.27%
  • No

    13 59.09%
  • What is a .sh file?

    3 13.64%
Results 1 to 10 of 10

Thread: General Question About Terminal Use

  1. #1
    Join Date
    Aug 2012
    Beans
    0

    General Question About Terminal Use

    I was just wondering that when you guys find lists of commands you need to put into the terminal does anyone else do what I do, that is paste them into a gedit or whatever text editing program and save as a .sh file to run in terminal. I am pretty sure I already know the answer, but i wanted to post this as a consensus kind of thing.
    Last edited by nbagf; March 29th, 2013 at 07:33 AM.

  2. #2
    Join Date
    Apr 2009
    Location
    UK Lake District
    Beans
    3,075
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: General Question About Terminal Use

    No
    I have a text file where I keep a list of commands to remind me and to look back at and can copy from
    Ubuntu Member Always something different. Promoting Ubuntu and System 76 at TUXPC

  3. #3
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    6,086
    Distro
    Ubuntu

    Re: General Question About Terminal Use

    I made a bunch of aliases, so typing commands I use a lot have been simplified.
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  4. #4
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: General Question About Terminal Use

    +1 for aliases.

  5. #5
    Join Date
    Dec 2008
    Location
    Indiana, United States
    Beans
    764

    Re: General Question About Terminal Use

    First line of documetnt is #! /bin/bash then everything after that is 1 line per command. You need to make it executable by running chmod +x /path/to/file before it will run. Then just cd to the directory the script is in and ./script.sh
    Whoever came up with the phrase "There is no such thing as a stupid question" obviously never had the internet.

  6. #6
    Join Date
    Aug 2012
    Beans
    0

    Thumbs up Re: General Question About Terminal Use

    Quote Originally Posted by deadflowr View Post
    I made a bunch of aliases, so typing commands I use a lot have been simplified.
    I did not know that that was possible until I googled it. This seems like a much more efficient way of initiating commands than pasting them into a .sh file. I guess my theory was wrong. I'm going to set some aliases up soon.

  7. #7
    Join Date
    Dec 2008
    Location
    Indiana, United States
    Beans
    764

    Re: General Question About Terminal Use

    Quote Originally Posted by nbagf View Post
    I did not know that that was possible until I googled it. This seems like a much more efficient way of initiating commands than pasting them into a .sh file. I guess my theory was wrong. I'm going to set some aliases up soon.
    They are both very useful. For example I use xfce with dual monitors. I need 3 separate commands to get everything working. But instead of trying to combine them into a single command I just use one command for monitor 1 one command for montor 2 and one command for setting the possition. I put those in an sh file and added my scripts folder to PATH in bashrc. So when it's time to start up the monitors all i have to do is type monitors into my terminal. Aliases can be useful so you don't have to remember a bunch of complex commands. Scripts are useful for when you want to run a single command but have multiple commands carried out without typing them all in. In other words aliases is just that you type in your nickname for a command and it's carried out. A script on the other hand carries out multiple commands at once in the order they where typed. Which makes it useful for automating some basic stuff
    Last edited by mamamia88; March 29th, 2013 at 02:29 PM.
    Whoever came up with the phrase "There is no such thing as a stupid question" obviously never had the internet.

  8. #8
    Join Date
    Jul 2007
    Location
    UK
    Beans
    17,004
    Distro
    Ubuntu Development Release

    Re: General Question About Terminal Use

    Quote Originally Posted by carl4926 View Post
    No
    I have a text file where I keep a list of commands to remind me and to look back at and can copy from
    I use ctrl r in the terminal to search for relevant commands I've used in the past.

  9. #9
    Join Date
    Dec 2008
    Location
    Indiana, United States
    Beans
    764

    Re: General Question About Terminal Use

    Also history or using the arrow keys up/down will display past commands. So if you only use a few no real need for aliases since you can just arrow up to the last command. Also if you are using a command but don't know all the available options you can type man command and it will give you detailed info on all the command is capable of
    Whoever came up with the phrase "There is no such thing as a stupid question" obviously never had the internet.

  10. #10
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    10,890
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: General Question About Terminal Use

    I write bash scripts all the time, if that's what you are asking about. Note that you do not need the .sh extension since Unix doesn't use extensions to identify executable files at all. A script can be called simply "myprogram", and it will run as a bash script as long as it is marked executable and has a first line that reads "#!/bin/bash".
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •