My first shell script. (Don't Kill Me)

Disclaimer: IHaveNoIdeaWhatImDoing.jpg

So over the past few days I have created this monstrosity:

My experience doing things like this was 0 prior to this. This combines several steps that I had to do when setting up Ubuntu on my 2013 Macbook Air. Pretty much combines things from these two pages:

After going through the things on these pages and finally getting everything to work I was kinda baffled that the people smart enough to get all of this to couldn't work it into an "installer".

I'm sure there are infinitely better ways to do this but this is what I have for now. It might be terrible but it works! I've already come across a couple methods I can use to make this better but that's gonna take some more learning before I'm ready to try to make it more advanced. I know it's not much but I'm pretty proud I actually got something to work (somehow).

I'd love to hear how many cardinal sins I've committed here and any suggestions to make it better! For my fellow Linux noobs out there, let this be a lesson to you. You CAN get shit to work. Trial and error my friends.

just fyi, you can use if, for etc statements for your bash scripts too. Bash is very easy, its same as windows batch files (just better).

Not that there are any reasons to buy an air now, how does it work with Linux, any speed or power problems?

Only issue I've noticed is wireless problems. It seems that my range is significantly less when using linux. Once you fix the issues listed on the pages I linked, everything works surprisingly well. Battery life is a little worse but nothing serious.

I suggest adding "sudo apt-get update && sudo apt-get upgrade" as the first line. So with a fresh install all packages with the repo are updated and to the latest version :)

1 Like

Didn't think of that. Thanks!

Yup, no problem :)

You should throw your script into a git repo and share it on This way you can track changes but more importantly people can help you improve or suggest new things.

I'm not understanding the MacBook Air part. You ran this on OS X, or you ran it on a MacBook Air running Ubuntu?

1 Like

Running Ubuntu. I use refind to dual boot OSX and Ubuntu. I'll look into github more this weekend.

Just something I like to add when i print something to the screen using echo and then proceed to do more things that would push that info text off the window is a sleep so like what i did with my script it pauses after the echos:

that way the user can see that text before the next line shoots it up off the screen.

1 Like

YES. I was wondering how this was done. I will definitely look into sleep. Thanks!

I see where you're coming from by using sleep that way, although I sort of disagree. In most scripts I write I don't really want to read what is being printed out. I want the script to either print the informational progress or be completely silent. What I'm most interested in is if an error occurred during one of the steps in the script or if the script completed successfully. This might be because when I run a script, I'm probably gonna run it in a new tab in the terminal and return to it later.

Don't get me wrong, if using sleep helps you manage and run you're scripts, more power to you. Keep on scripting.

Ya, It's just my personal preference, I like to see what the script is doing. Even though I wrote it. Lol, and that one was to be used by another it guy who doesn't necessarily know linux that much. So, I wanted to have it show it was in fact doing something.