LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Scripting advise (https://www.linuxquestions.org/questions/linux-newbie-8/scripting-advise-4175461693/)

YesNew2linux 05-12-2013 11:13 PM

Scripting advise
 
Hello everyone. I'm a little new to Linux but I have a basic programming background and would like to know which would be a preferred scripting language. Is python better or is bash scripting better?

Thanks

chrism01 05-12-2013 11:27 PM

bash is the (usual) cmd line shell language, so I'd start with that, to get familiar with Linux & scripting.
After that, there is range of languages you can look at.

Try these for Linux/bash
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

pan64 05-13-2013 12:43 AM

Quote:

Originally Posted by YesNew2linux (Post 4949857)
Is python better or is bash scripting better?Thanks

Actually bash is a must, you will not be able to do anything without it. The next step can be any other language (like python)

unSpawn 05-13-2013 01:38 AM

Indeed BASH is a must.

BASH intros:
http://www.gnu.org/software/bash/man...ode/index.html
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html

BASH scripting guides:
http://mywiki.wooledge.org/BashGuide
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
# these are must reads so do read them!

Common questions / problems:
http://mywiki.wooledge.org/ParsingLs
http://mywiki.wooledge.orgDontReadLinesWithFor
http://mywiki.wooledge.org/UsingFind
http://mywiki.wooledge.org/Arguments
http://mywiki.wooledge.org/WordSplitting
http://mywiki.wooledge.org/Quotes

Also see:
http://www.linuxquestions.org/questi...l-links-35334/

The Advanced BASH scripting guide:
http://www.tldp.org/LDP/abs/html/

Bourne shell (compatibility):
http://www.grymoire.com/Unix/Sh.html

konsolebox 05-13-2013 05:18 AM

Bash can do many system/world-level solutions and is easy when a quick solution is needed. Please check Ruby as well.

kooru 05-13-2013 05:32 AM

Hi and welcome to LQ!
Bash, of course.

tronayne 05-13-2013 08:22 AM

The shell, be it BASH (Bourne Again Shell), ksh (KornShell), sh (the original shell program developed primarily by Stephen Bourne at Bell Labs for Unix), the C-Shell (developed at Berkeley) along with various flavors and variants are command and programming languages.

When you fire up a Linux system and log in, you're presented with a shell prompt (if the system starts at run level 3 (non-graphic); if it starts with GNOME, KDE, Xfce or some other window manager you need to open a terminal emulator to get a shell prompt.

From that prompt, you can execute programs and utilities piping the output of one program into the input of another program as necessary or you can write a shell program ("script" isn't really correct, what you're actually doing is writing a shell program that you can save as a file, make it executable and then type its name to execute it) to perform useful work (hopefully!). Shell programming has grammar and syntax rules just like any programming language (C, FORTRAN, whatever). You may be surprised how many shell programs there are on your system; e.g.,
Code:

cd /usr/bin
file * | grep POSIX

(that should be over 400). One example that is frequently used is whatis; it's a shell program (on most systems). Back in the day, when Unix was developed, folks worked on terminals; from Teletypes to video, keyboard and display integrated in one box, no graphics (other than curses), text all the way and did a great deal of useful work. Truth is, you still can -- if you know the grammar and syntax, that is.

It's really a good idea, if you're serious about getting the most out of your system, to take the time to learn shell programming. At some point, you're going to hit a problem you need to solve and you won't be able to do it with some pre-built application -- if you know how to write a shell program, you can, typically, solve a problem without resorting to a higher-level programming language (not always, certainly, but more frequently than you might think).

It's worth your time to learn.

Hope this helps some.

YesNew2linux 05-14-2013 04:27 PM

Thanks everyone. Having a feeling I am gonna enjoy being a member :)

vickynash 05-14-2013 05:47 PM

thank you tronayne, those lines did help me, worth reading as same worth learning bash :)


All times are GMT -5. The time now is 04:24 PM.