I have seen one shell script starting with the below code :-
#!/bin/bash
currfoldername=$1
cd $currfoldername
can anyone describe what does $1 mean here?
Thanks for your reply!!
I have seen one shell script starting with the below code :-
#!/bin/bash
currfoldername=$1
cd $currfoldername
can anyone describe what does $1 mean here?
Thanks for your reply!!
$1 means the first argument given while executing the shell script.
Example -
# my_script.sh
#!/bin/bash
currfoldername=$1
cd $currfoldername
echo "in $currfoldername"
execute -
./my_script.sh my_folder
output -
# value of variable currfoldername is my_folder.
#cd to my_folder
in my_folder # echo statement