Need to understand shell script

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to understand shell script
# 1  
Old 10-25-2013
Need to understand shell script


Can someone please help me understand the shell script below for installing Jboss EAP 6? It is from, what does the highlighted code mean?

# Load Java configuration.
[ -r /etc/java/java.conf ] && . /etc/java/java.conf
export JAVA_HOME

# 2  
Old 10-25-2013
Have look at the manual page for test

Does that make it any clearer? It's better for you to learn it than for me to just tell you an answer, but I will happily do so if it still doesn't make sense.

This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 10-25-2013
# Load Java configuration.

[ -r /etc/java/java.conf ] \               # what is in between []  is a condition expression, -r expects 
a file after which is the case here and is true if it exists and readable by the current process
&&\      # if success execute what follows:
 . /etc/java/java.conf   
export JAVA_HOME

This User Gave Thanks to vbe For This Post:
# 4  
Old 10-25-2013
Thanks! Found

# man test
              FILE exists and read permission is granted

I also learned that && means more than the traditional AND. But what does the dot mean in the following code. I assume it does NOT mean the current directory.

. /etc/java/java.conf

# 5  
Old 10-25-2013
. means 'run this program inside your own shell'. This allows it to set variables inside your shell, which wouldn't be possible if you ran a script with ./scriptname -- when you create a new process its variables are separate.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to understand special character for line reading in bash shell?

I am still learning shell scripting. Recently I see a function for read configuration. But some of special character make me confused. I checked online to find answer. It was not successful. I post the code here to consult with expert or guru to get better understanding on these special characters... (3 Replies)
Discussion started by: duke0001
3 Replies

2. Shell Programming and Scripting

Need help to understand the below shell script

Please help me to understand the below 3 lines of code.execute shell in jenkins 1)APP_IP=$( docker inspect --format '{{ .NetworkSettings.Networks.'"$DOCKER_NETWORK_NAME"'.IPAddress }}' ${PROJECT_NAME_KEY}"-CI" ) 2)HOST_WORKSPACE=$(echo ${WORKSPACE} | sed... (1 Reply)
Discussion started by: naresh85
1 Replies

3. Shell Programming and Scripting

Need to understand how the line in perl program works as shell commend

Discussion started by: digioleg54
2 Replies

4. Shell Programming and Scripting

I am learning shell scripting and i would like to understand how sort -k3,3 -k 4,4 short* works

Please help me understand how sort -k3,3 -k 4,4 short* works , is it sorting 3 and 4 th field ? what is the use of specifying 3,3 and 4,4 in sort and what is actually does and i see sort -k3 short* and sort -k3,3 -k 4,4 short* giving the same output. Sort output attached Please help (2 Replies)
Discussion started by: Antony Ankrose
2 Replies

5. UNIX for Dummies Questions & Answers

Help with understand shell script coding

Good afternoon everyone, I am very new to UNIX shell scripting and I am trying to understand the following code. I know what it does but I need to modify it so it will allow me to pass a file name as *FILENAME* Thank for any guidance offered. if ] ; then match=`expr "$file" :... (2 Replies)
Discussion started by: Walter Barona
2 Replies

6. Shell Programming and Scripting

Need to understand a couple of Shell Logic

Hi, I am trying what the following loop does : for i in XYZ do for j in M1 R1 R2 R3 do if then kList="" n=1 while do kList="$kList $n" let n++ done There are a couple of loop as mentioned above for R1.R2.R3. (1 Reply)
Discussion started by: johnprince1980
1 Replies

7. Shell Programming and Scripting

Understand a old unix shell script

Hi All, I have a unix old script i but i am not able to understand the few commands in it and what it does. below is the script. if ; then for F in $(find $DIR/. ! -name . -prune -name "DP_*.dat") do IN=${F##/*/} OUT='ORD'$(echo $IN | cut -c7-) exec.ksh $IN... (2 Replies)
Discussion started by: kam786sim
2 Replies

8. Shell Programming and Scripting

I need to understand the differences between the bash shell and the Bourne shell

I do not claim to be an expert, but I have done things with scripts that whole teams of folks have said can not be done. Of course they should have said we do not have the intestinal fortitude to git-r-done. I have been using UNIX actually HPUX since 1992. Unfortunately my old computer died and... (7 Replies)
Discussion started by: awk_sed_hello
7 Replies

9. UNIX for Dummies Questions & Answers

Help required to understand a variable in shell script!!!

Hi, I need to understand the following script: a=`dirname $0` b=`uname -s` if ; then c=$a/../../../platforms/$b/extlib else c=`pwd`/$a/../../../platforms/$b/extlib fi There are a bunch of variable assignments going on here!!! What does this variable means: "${a:0:1}" ... (2 Replies)
Discussion started by: abhishek2301
2 Replies

10. Shell Programming and Scripting

bash shell: 'exec', 'eval', 'source' - looking for help to understand

Hi, experts. Whould anybody clear explay me difference and usage of these 3 commands (particulary in bash) : exec eval source I've tryed to read the manual pages but did not get much. Also could not get something useful from Google search - just so much and so not exactly, that is... (3 Replies)
Discussion started by: alex_5161
3 Replies
Login or Register to Ask a Question