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 bash coding?

507


What does $$ mean in shell script?

595


How to check if the previous command was run successfully?

599


How can the contents of a file inside jar be read without extracting in a shell script?

601


What is the use of a shebang line?

627






How to calculate the number of passed arguments?

558


What are the different commands available to check the disk usage?

499


What is c in shell script?

645


What does $0 mean in shell script?

565


What is difference between shell and bash scripting?

551


How do I start a shell script?

583


What are the disadvantages of shell scripting?

645


What is echo in shell?

642


What is the first line in every perl script called?

561


Why should we use shell scripts?

601