How to echo output of a UNIX command (like ls -l ) using shell script.?

How do i echo the output of a unix command using shell script???

Like:
echo /etc/ ls -l

http://ss64.com/nt/syntax-redirection.html

ls -l >nul 2>&1
1 Like

I am a little confused as to what you're really trying to do. But assuming you want to display the output of a command via a shell script, here's what you should do:
Create a script, say test.sh, with the following contents:

#!/bin/bash
ls -l

The code snippet above assumes you are using the bash shell. For other shells you need to find the path to them (for ksh, it should be /bin/ksh ).
Give the script permissions to execute:

chmod 755 test.sh

Then run the script:

./test.sh

You should see displayed the output of the ls -l command in your screen.
I would highly recommend you take a look at The Linux Command Line, which IMHO is the best Linux book for starters (and for seasoned users as well!). This and many other essential topics are explained in detail. Also, you can download it for free from the link above.
Hope it helps.