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

How will you copy a file from one machine to other?

543


What is the command to find out users on the system?

568


How will you find the 99th line of a file using only tail and head command?

1974


What is the use of "$#" in shell scripting?

548


How to get the first line from a file using just the terminal?

592






How do I set bash as default shell mac?

552


What command needs to be used to take the backup?

524


Differentiate between ‘ and ” quotes.

606


What is eval in shell script?

643


How to print the first array element?

548


Determine the output of the following command: [ -z “” ] && echo 0 || echo 1

553


What does .sh file contain?

548


How are shells born?

546


Can you write a script to portray how set –x works?

546


What are scripts in psychology?

588