What is difference between POSIX, Bash and other shells for scripting?
Solution 1
Your question is too big to answer in anything but general terms.
POSIX is a family of operating system interface standards; you generally write code / run utilities in a conformant fashion when you want your application to run across a wide variety of Unix-ish systems. As popular as the GNU binutils and bash are, they are not used universally, so sticking to POSIX-conformant functions, flags and utilities can save you some headaches when the time comes to move an app from say Linux to Mac OS.
"Advanced scripting" isn't descriptive enough to recommend a language, but if what you're doing mostly is running programs and using other program to process the results, the shell is the right tool for that. I don't think it matters much which shell you use, since the usual ones are all portable and can be built and installed along with your app. But if you're using data structures beyond one-dimensional arrays, you should be using a language that more easily manipulates such structures, e.g. Perl.
Solution 2
Which one of them is the most widely used?
Bash
is the most popular for common tasks not requiring portability.
POSIX
is the only way to make your script portable.
What portability means
It means to be able to run your script on almost any Linux, and alike-platforms such as Cygwin or Android. Though, be aware that it requires some skill to be able to script POSIX-ly. Examples are out of the scope of this Q & A. Feel free to look around U & L.
Related videos on Youtube
ekoeppen
Updated on September 18, 2022Comments
-
ekoeppen over 1 year
While going through many answers on Unix & Linux, I came across many of them writing their contents and tags with POSIX or Bash or some other standard Linux shell.
I know of some differences like some of them have arrays and some do not, and other system level differences which I am not completely aware of.
Question Which one of them is the most widely used? Is there a long term benefit sticking to one over the other?
What are the things that matter for a Bash script writer to begin scripting in another shell?
-
user12711 over 4 yearsbash can run in POSIX compliant mode "bash --posix" at your bash command prompt will enter this mode. to exit, simply type "bash" again, in your terminal. Bash is intended to be a conformant implementation of the Shell and Utilities portion of the IEEE POSIX specification (IEEE Standard 1003.1). Bash can be configured to be POSIX-conformant by default. (according to the "man bash" description)