Indent output of an UNIX command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Indent output of an UNIX command
# 1  
Old 12-06-2005
Indent output of an UNIX command

Hi,

How do I indent 4 spaces for standard UNIX commands like ls -ltr (or grep)?
For example, I want ls -ltra to output as:

<<spaces here>>-rw-r----- 1 a345696 rtkdevel 455 Dec 6 14:52 file1
<<spaces here>>-rw-r----- 1 a345696 rtkdevel 455 Dec 6 14:52 file2
<<spaces here>>-rw-r----- 1 a345696 rtkdevel 455 Dec 6 14:52 file3

instead of:

-rw-r----- 1 a345696 rtkdevel 455 Dec 6 14:52 file1
-rw-r----- 1 a345696 rtkdevel 455 Dec 6 14:52 file2
-rw-r----- 1 a345696 rtkdevel 455 Dec 6 14:52 file3



I tried to do it with a functions which indents it's argument, but it did only for the last line of the output.

Any clues?

Thanks in Advance,
Suddha Satta Ray
# 2  
Old 12-06-2005
my_command_here | sed 's/^/ /'

Cheers
Zb
# 3  
Old 12-08-2005
Thanks!!
Works perfectly!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX command output format in email is not same as on the system

Hi I have script to collect file system usage statistics from few remote unix hosts and email . On the UNIX system the column spacing is fine but the email output is not aligned properly. Any tips to fix this ? (1 Reply)
Discussion started by: new2prog
1 Replies

2. Shell Programming and Scripting

Compare output of UNIX command and match data to text file

I am working on an outage script and I run a command from the command line which tells me the amount of generator failures in my market. The output of this command only gives me three digits to identify the site by. I have a master list of all sites in a separate file, call it list.txt. If my... (7 Replies)
Discussion started by: jbrass
7 Replies

3. Shell Programming and Scripting

Expect - assigning UNIX command output to a variable

Hi, I'm writing a script that connects through ssh (using "expect") and then is supposed to find whether a process on that remote machine is running or not. Here's my code (user, host and password are obviously replaced with real values in actual script): #!/usr/bin/expect set timeout 1... (3 Replies)
Discussion started by: oseri
3 Replies

4. Shell Programming and Scripting

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 (2 Replies)
Discussion started by: sunny2802
2 Replies

5. Shell Programming and Scripting

UNIX command output in csv format

I'm just wondering is there any way to capture the output of a unix command in a csv format. df -h gives the result of filesystem,free space,Used space, use %,mounted on. Is there a way to capture the command output and format it as comma sparated or fixed length file. (3 Replies)
Discussion started by: anita81
3 Replies

6. UNIX for Dummies Questions & Answers

UNIX command output format

how can I get the df -h command output into excel format or csv file. df -k | tr -s " " | sed 's/ /, /g' | sed '1 s/, / /g' | column -t df -h | column -t I have tried as above but the format is not right. I'm not able to load the format into a excel or a table. ... (2 Replies)
Discussion started by: anita81
2 Replies

7. Shell Programming and Scripting

Unix shell command output to a sql statement

Can i do this Say one command sed 's/:*/ /g' $summf is returning C1234 C2345 C3434 some no of rows, now this ouput i have to insert it into a DB table how do i do this?? (2 Replies)
Discussion started by: depakjan
2 Replies

8. UNIX for Advanced & Expert Users

Output of Free command in unix?

Hello, I need some help to interpret the below output... What is -/+ buffers/cache? My understanding is, total RAM is 3986152 Bytes, used RAM is 3950904 bytes. What is buffers and cached?? Can any one please interpret this output? It would be great help if some one can help me on this? ... (2 Replies)
Discussion started by: govindts
2 Replies

9. UNIX for Dummies Questions & Answers

Logging Command Line and Output in Unix

Hi, This might be a bit stupid question, but what command to use to create like a session which logs the command line, and output on to the screen? Basically, a log to a file, where I can review what I had install, uninstall, etc. Thank you (4 Replies)
Discussion started by: kittoinc
4 Replies

10. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies
Login or Register to Ask a Question