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 will you suspend a running process and put it in the background?

1012


I am using RedHat 6.3 in I wanna to install and configure zimbra mail. Can anybody tell me what are the RPM packages required for zimbra mail ? Where can I get those RPM packages ?

1168


You need to see the last fifteen lines of the files dog, cat and horse. What command should you use?

526


Which command puts a script to sleep untill a signal is recieved?

629


What does touch do in linux?

510






What is nslookup command?

515


How do you save a file in linux?

561


What is the command can be run to remove all the rules in an iptable table?

566


What command should you use to check your file system?

519


What is the command to calculate the size of a folder?

500


What does curl command do in linux?

482


Explain trap command; shift command, getopts command of linux?

559


What is the copy command in linux?

465


How do I clear terminal command history?

553


What does chmod 666 do?

527