Thursday, 22 August 2019

Getting started with Unix

chmod +x test.sh
this is the command used to make file executable
To execute File
./test.sh

Date used to get date
date

Creat a file

vi hello.sh

inser code

esc + I

Save code  and quit

esc + :wq

if file is readonly use

:wq!

Give access to execute

chmod +x hello.sh       or      chmod 755 hello.sh

Execute Script

./Hello.sh


See what is the content of this file

cat Hello.sh

Exporting values in Unix for Variables


I have a script

echo " VAR VALUE IS $VAR1"
$VAR1="hello"
echo"NEW VAR VALUE IS  $VAR1"

output

run using ./hello.sh

Var value is

New var value is hello


if you define  $VAR in command prompt before running

$VAR = OLDHELLOW

It wont recognize this running ./hello and out put will be same


run using ./hello.sh

Var value is  

New var value is hello


To make it global we need to export this value using

export VAR
run using ./hello.sh

Var value is  oldhello

New var value is hello


But in our interactive shell the value will still be old hello even though we assign it hello.


To know your current location use

pwd

command.


Location for Java on Unix is

/usr/local/<java_Install>

To remove file preds.jar

rm preds.jar


To view Contents of Jar file

jar tvf Name_Of_JarFile

No comments:

Post a Comment