Grep commands & format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep commands & format
# 1  
Old 06-07-2013
Grep commands & format

I have these grep commands and need to put them next each other (in horizontal layout).
Code:
cat /tmp/dsmc.out |grep Done
cat /tmp/dsmc.out |grep "Elapsed processing time:"
cat /tmp/dsmc.out |grep "Client date/time:"
cat /tmp/dsmc.out |grep "Total number of bytes transferred:"

so that it shows as:

Done "Elapsed processing time:" "Client date/time:" "Total number of bytes transferred:".

Please advise.
# 2  
Old 06-07-2013
paste command

Try the
Code:
paste

command to place the output horizontally
This User Gave Thanks to krishmaths For This Post:
# 3  
Old 06-07-2013
You mean the outputs? also dont use cat when you are using grep/sed/awk they are capable of reading the file..
This User Gave Thanks to vidyadhar85 For This Post:
# 4  
Old 06-07-2013
Sorry, how do you use
Code:
paste

in this case?
# 5  
Old 06-07-2013
Try:
Code:
grep -e "Done" -e "Elapsed processing time:" -e "Client date/time:" -e "Total number of bytes transferred:" /tmp/dsmc.out | paste - - - -


Last edited by Scrutinizer; 06-07-2013 at 02:18 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 06-07-2013
Be careful: different from using 4 greps in a sequence, using one grep with 4 expressions does not guarantee the order of output elements that the requestor perhaps wants.
This User Gave Thanks to RudiC For This Post:
# 7  
Old 06-08-2013
This file contains command output and then typically the order within a record will be maintained. The alternative would be to fill 4 separate files with 4 separate greps and then paste those files. But either way the correct presentation of those fields needs those 4 fields needs to be present exactly once per record, then either method should work.

Otherwise we would need to create an script that does this, with awk for example. We can make it ever more complex, but if a simple solution works in practice, then why not use that instead? That is why I asked the OP to try and see if it works. He can easily verify if it renders the desired result..
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File System & commands

Hello! Is File System stored in unix kernel or in pc memory? Are unix commands stored in kernel? many thanks! (1 Reply)
Discussion started by: pinklemon
1 Replies

2. Shell Programming and Scripting

Using Grep & find & while read line in a script

Hello people! I would like to create one script following this stage I have one directory with 100 files File001 File002 ... File100 (This is the format of content of the 100 files) 2012/03/10 12:56:50:221875936 1292800448912 12345 0x00 0x04 0 then I have one... (0 Replies)
Discussion started by: Abv_mx81
0 Replies

3. Shell Programming and Scripting

[Solved] Problem with mail commands & format

1. I generated a log for the script. log: abc def ghi ijk If I use general (plain text) format for mail sending, it was displaying correctly with new lines where I have. Eg: abc def ghi ijk But I tried with HTML format using the code: (8 Replies)
Discussion started by: karumudi7
8 Replies

4. Shell Programming and Scripting

Sort a the file & refine data column & row format

cat file1.txt field1 "user1": field2:"data-cde" field3:"data-pqr" field4:"data-mno" field1 "user1": field2:"data-dcb" field3:"data-mxz" field4:"data-zul" field1 "user2": field2:"data-cqz" field3:"data-xoq" field4:"data-pos" Now i need to have the date like below. i have just... (7 Replies)
Discussion started by: ckaramsetty
7 Replies

5. Shell Programming and Scripting

Append && echo "success" to all commands

I am learning to build from SVN and other tools, with a lot of copying and pasting from forums. I like to append && echo "success" to all commands so that I can see at a glance if things went all right. Is there a way that I can have the bash shell append this to all commands? Thanks! (5 Replies)
Discussion started by: dotancohen
5 Replies

6. UNIX for Dummies Questions & Answers

Difference between grep, egrep & grep -i

Hi All, Please i need to know the difference between grep, egrep & grep -i when used to serach through a file. My platform is SunOS 5.9 & i'm using the korn shell. Regards, - divroro12 - (2 Replies)
Discussion started by: divroro12
2 Replies

7. UNIX for Dummies Questions & Answers

Find & If commands together

Hi to everybody!! I have a (simple) question but i am newbie with unix and so i need a little help...I am writing a bash script file and i want to put inside this: i have this command " find /usr/bin -name bzip2 -print " that i want to put it in a "if" statement and when it returns true the... (6 Replies)
Discussion started by: orestis7
6 Replies

8. UNIX for Dummies Questions & Answers

help with find & grep commands

Folks; First about find: when i run this: find . -name '*log*' -mtime +10 -print | sed 's+^\./++;s+/.*++' | sort -u i got list of log files but also get a directories (although directory names doesn't have "log" in it). How can i exclude the directory from the output of this find command? ... (2 Replies)
Discussion started by: moe2266
2 Replies

9. SCO

compress & cpio commands

Our End of Day backup routine uses following script. start End-of-day compress $BASE TO /home/compdir write /home/compdir to DATTAPE end where $BASE=/home2/Rev83 DATATAPE=/dev/rmt/ctape1 write=cpio (not sure about parameters) since I'm new to UNIX, i dont know how to restore data... (1 Reply)
Discussion started by: tayyabq8
1 Replies

10. Shell Programming and Scripting

Numbers & stack commands

Hi everyone, Sorry I keep asking these stupid perl questions here. They're not any sort of assignment or anything like that, I'm just browsing through the book "Learning Perl" and I'm finding that I can do some of their practice exercises just fine, but others give me some trouble. Right now... (1 Reply)
Discussion started by: jason_v
1 Replies
Login or Register to Ask a Question