A little help please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A little help please
# 8  
Old 11-14-2007
The leading "$ " is the prompt, so you don't type that.
# 9  
Old 11-14-2007
Have you covered variables and how they work and how they are expanded by the shell?

You can do alot of playing around with variables purely with "echo"

Code:
FOO=foo
BAR=bar
echo $FOO
echo $BAR
echo $FOO $BAR
echo $FOO                         $BAR
echo "$FOO                        $BAR"

and some more

Code:
FLIM="flim         "
FLAM="        flam"
echo $FLIM
echo $FLAM
echo "$FLIM"
echo "$FLAM"
echo $FLIM $FLAM
echo "$FLIM $FLAM"

# 10  
Old 11-14-2007
yes i have been through variables.

enter after the leading $

str1=abcd
test $str1 = abcd

then what can i do after this to get my exit result of 0.
# 11  
Old 11-14-2007
$? is a variable that holds the return code of the last command.

Code:
echo $?

also

$$ is a variable that holds the current process id
$! is a variable that holds the pid of a process launched asynchronously
$0 holds the current script name
$1 ..... hold each argument from the command line
$@ holds all the command line arguments
# 12  
Old 11-14-2007
Thanks prorter i got it now. Smilie

Any chance you being able to do any of the above scripts and then going through them with me.
# 13  
Old 11-14-2007
I suggest you take the first one and have a go.

Start the file with

Code:
#!/bin/sh -x

call it something sensible and then do

Code:
chmod +x myscript.sh

so that the operating system know it can run it.

The -x option will make the shell spit out the detail of what it is really doing.
# 14  
Old 11-14-2007
Iv created a file called filex and i have inserted the env details to it.

Did this by touch filex
then env > filex
checked to see if file has got the correct content in by cat filex.

Then iv created a script by creating a file - touch firstline
and the opening it in vi editor.

Does my first line not have to #!/bin/bash or what u have stated.

get stuck here...
This User Gave Thanks to immyakram For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question