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 are "c" and "b" permission fields of a file?

742


What is the significance of $#?

766


How to print all array elements and their respective indexes?

692


determine the output of the following command: echo ${new:-variable}

720


What is scripting used for?

742


Explain about shebang?

797


How can you get the value of pi till a 100 decimal places?

730


What is web script?

758


What is a scripting language simple definition?

774


How do I run a shell script in powershell?

748


What is the difference between bash and shell?

820


What is console line?

729


Why are shell scripts used?

799


c program which behaves like a shell(command interpreter). it has its own prompt say "NewShell$".any normal shell command is executed from your shell by starting a child process to execute a system program corrosponding to the command

4919


What are the 3 standard streams in linux?

744