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.?

Answers were Sorted based on User's Feedback



How do you print the output the same string which is typed in command line. how do you write the sh..

Answer / santana20142003

$read line ---> it will read
$ echo $line ---> it will display

Is This Answer Correct ?    6 Yes 0 No

How do you print the output the same string which is typed in command line. how do you write the sh..

Answer / asit

echo "$*"

Is This Answer Correct ?    1 Yes 0 No

How do you print the output the same string which is typed in command line. how do you write the sh..

Answer / 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

More Shell Script Interview Questions

how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example

4 Answers  


Why is a script important?

0 Answers  


What is a file basename?

0 Answers  


What is the way to do multilevel if-else's in shell scripting?

0 Answers  


How to print pid of the current shell?

0 Answers  






There is a record with fields namely name,roll no.,salary,grade etc.Now,write a script to create a file with multiple records have same combination of fields but with unique roll numbers.The script should work for different names in the input file.

1 Answers   Wipro,


What makes c shell a more preferable option than the bourne shell?

0 Answers  


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

0 Answers  


What is difference between bash and shell?

0 Answers  


How does path variable work?

0 Answers  


What is the use of echo in shell script?

0 Answers  


What are the advantages of using shell scripts?

0 Answers  


Categories