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

Why is the use of shell script?

541


What is the best scripting language?

562


Explain about debugging?

606


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

542


What does $1 mean in bash?

614






Explain about gui scripting?

622


Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.

2170


How do I stop script errors?

573


What is batch file programming?

689


write a shell script to check the failed jobs?

3952


What is shell scripting?

585


How to write a function?

592


What is the fastest scripting language?

547


How do I start a shell script?

570


Why is it called a shell?

505