0

I am a beginner in Scripting and I want to know the following differences in shell

  • difference between if [ condition ]; then and if [[ condition ]]; then
  • I have this var=$(diff file1.txt file2.txt) Why do i need to put $ before the bracket?
  • When do I need to use {} in shell? Why would I use it (except for arrays)?
  • Is there somewhere I can go to see the difference between Linux shell and Solaris Shell? They aren't the same. I am trying to optimize a shell code with written in linux OpenSuse with shebang #!/bin/sh for solaris. However, I've notice that the code does not work on Solaris. However, it works perfectly in Linux. So I was wondering how or where can I read about it and optimize my code so it woks on Solaris as well.

thank you in advance

Matt
  • 853
  • 1
  • 13
  • 30
  • 2
    Sorry, but you should have one question. These are all very unrelated to each other and there are duplicates for probably all of these... (The first one is addressed [here](http://stackoverflow.com/questions/3427872/whats-the-difference-between-and-in-bash)) For the Solaris question, see what Linux says when you type `echo $SHELL` and the difference will be the difference between those two shells. Or you could set Solaris to use `bash` and write scripts just for that. – beroe Oct 18 '13 at 17:53
  • Many, but not all, Linux distributions use `bash` as their system shell. Solaris uses a variant of `ksh`, I believe. On either machine, you should be able to run `man sh` to get the manual page for the appropriate shell. That should give you the answers to the first three questions, as well as providing the necessary understanding for modifying your existing code. – chepner Oct 18 '13 at 18:16
  • 1
    @chepner - Solaris 10 and older use an ancient, pre-POSIX bourne shell as the system shell; Solaris 11 and later use ksh93. Both have `/bin/bash` available as well. – alanc Oct 19 '13 at 15:19

0 Answers0