Quote:
Originally Posted by sharee
Is one better than the other? Bash scripting in Ubunu is something new for me and I kind of like it. Its similar to programming, in a sense. I have not had the opportunity to perform bash scripting in Linux. It seems like once you learn the commands and how too use them, it becomes easier to bash script.
|
Bash has its origins in the "command shell" -- a place outside the kernel (hence "shell") where users could enter commands, have them executed and the results displayed, in the same way as is done at the DOS prompt or the Windows command prompt (in case you are familiar with those). But bash has evolved from UNIX's command shells and UNIX's developers were, er, developers so they made a great tool, something more than a simple place to run commands. Being programmers they naturally gave it program-like capabilities including the genius idea -- a cornerstone of UNIX -- of "piplelining" command together so the output of one could be fed to the input of another and so on thus establishing the UNIX idea of single-purpose tools that could by strung together.
As UNIX/Linux shells have evolved they have gained more programming facilities and are now quite sophisticated in their own right -- functions, recursion, arrays, conditionals, string-manipulation, command output substitution ... and some once external commands have been built in for performance (test and echo are good examples) but bash can use all available commands in a more integrated way than other languages do with their "system" functions.
So yes -- bash scripting is very "
similar to programming" and the more "
you learn the commands and how too use them", the more you can do with bash scripts.
Beware bash' weaknesses though -- as always it's "horses for courses". Bash is slow at handling large strings and bash has to create a new process to run each external command which is quite slow and expensive in system resources.
EDIT:
Regards ubuntu/Linux, as has already been pointed out, ubuntu is a Linux-based product and bash is more-or-less identical wherever you find it. One difference not mentioned is that not all Linux-based "distros" have the same commands and, even if they do have the same commands, the format of output from those commands may be different. This makes it non-trivial to make "portable" bash scripts that can be run without change on a wide variety of systems.