Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Hi, I am new to linux. Don't hesitate if I ask a silly queston.  (Read 4097 times)

0 Members and 1 Guest are viewing this topic.

saidulu.alli

  • Guest
Hi, I am new to linux. Don't hesitate if I ask a silly queston.
« on: October 14, 2008, 05:10:25 AM »
When you assign a value $1 to some variable, what actually it assigns.

for example Build_dir = $1;

what is the value of Build_dir ?

Dias de verano

  • Guest
Re: Hi, I am new to linux. Don't hesitate if I ask a silly queston.
« Reply #1 on: October 14, 2008, 11:53:42 AM »
Quote
what is the value of Build_dir ?

Did you mean in a script? If so, then $1 is whatever is the first argument on the command line. If myscript.sh contained this line:

Build_dir = $1;

... and you called it like this...

sh myscript.sh /home/myfolder

... then Build_dir would have the value /home/myfolder.

     $$ = The PID number of the process executing the shell.
     $? = Exit status variable.
     $0 = The name of the command you used to call a program.
     $1 = The first argument on the command line.
     $2 = The second argument on the command line.
     $n = The nth argument on the command line.
     $* = All the arguments on the command line.
     $# The number of command line arguments

surekha



    Greenhorn

    Re: Hi, I am new to linux. Don't hesitate if I ask a silly queston.
    « Reply #2 on: October 14, 2008, 09:21:43 PM »
    hey in scripting the first argument through commandline is considered as $1 if u fail to give arguments .
    you should display an error message and ask for entering arguments


    $1 is th argument which u enter after the filename in commandline
    Love all        Trust few         Follow one

    pcgeek



      Rookie

    • Pc Geek is my name and computer security is my aim
      Re: Hi, I am new to linux. Don't hesitate if I ask a silly queston.
      « Reply #3 on: October 20, 2008, 06:22:19 AM »
      thanks that helps. I wanna learn more linux stuff grrrrrrrrr  :-[
      A hot computer security geek is officially a pc geek!
      http://hotpcgeek.wordpress.com