what is the command To print script arguments

Answer Posted / shabab

$* and $@ are the right answers

$# - prints out the number of arguments passed

Consider the below code
########################
for i in "$*"
do
print $i
done

for i in "$@"
do
print $i
done
########################

and you call the script by saying

#samp.sh hai welcome to "Unix Forum"
hai welcome to Unix Forum
hai
welcome
to
Unix Forum


The first line is the output by printing out $*
the next four lines are with the help of $@.

So
$* will combine all arguments to a single string
$@ will have each arguments as a seperate string

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How use linux command line?

760


How do I find my user id in linux?

706


What is the use of man command in linux?

757


What is the command can be used to check for file corruption?

782


How do you insert comments in the command line prompt?

925


What does ls mean in linux?

785


Which command is used to uncompress gzip files?

824


How do you limit memory usage for commands?

778


Is cmake only for c++?

752


What are linux commands useful?

774


You are required to restore the file memo.ben. It was backed up in the tar file MyBackup.tar. Which command would you use to do it?

733


You wish to print the file vacations with 60 lines to a page. Which of the following commands will accomplish this?

685


What is devops linux?

700


Which commands are used to set a processor-intensive job to use less cpu time?

774


How do you open a command prompt when issuing a command?

729