How do you print the output the same string which is typed
in command line. how do you write the shell script or
command for this. if i entered "Hello" in command line, it
should print 'Hello', if i say "Hello Welcome", i should get
the "Hello Welcome" as output.?

Answer Posted / nirmala

1)If you type "hello" in command line your script should be
written as below

echo $1

2)If you type "hello world" in command line your script
should be written as below

echo $*

3)If you type "hello" and "hello world" in cmd line and
your file name is"string" script is as written below

echo $1
shift 1
echo $*

i/p: string hello hello world
o/p:hello
hello world

Is This Answer Correct ?    0 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is eval in shell script?

653


How will you connect to a database server from linux?

557


Is shell and terminal the same?

593


What are types of shells?

549


How to find duplicate record in file using shell script?

850






What are zombie processes?

571


How do I run a script on mac?

570


What exactly is a shell?

606


What are different types of shell?

496


How do we create command aliases in a shell?

542


I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?

754


I have to write Shells (Linux + Unix)for publishing packages and reports. Is it possible ? What are the differents executable programs ineed to call ?

1685


What is a file basename?

594


What language is bash?

491


Why do we write bin bash in shell scripts?

546