Grep result from dd command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep result from dd command
# 1  
Old 05-06-2014
Grep result from dd command

Hi,

I am running following command in a bash script for testing IO and use grep to get throughput number, but it did not work, it displayed everything:

Code:
dd if=/dev/zero of=/dev/null bs=1G count=1 oflag=dsync | grep bytes | awk '{print $7}'

1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 8.857 s, 60.6 MB/s

How can I extract only the result "60.6 MB/s"?

Also, can I have timeout if it takes too long?

Thank you
# 2  
Old 05-06-2014
Try:
Code:
dd .... 2>&1 | grep ....

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 05-06-2014
In addition to what Scrutinizer said, $7 in the last line of output from dd is s,; not 60.6 MB/s. And you don't need both grep and awk. Try:
Code:
dd if=/dev/zero of=/dev/null bs=1G count=1 oflag=dsync 2>&1 | awk '/bytes/{print $(NF-1), $NF}'


Last edited by Don Cragun; 05-06-2014 at 03:27 AM.. Reason: Switch back to original dd parameters.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep command giving different result for different users for same command

Hello, I am running below command as root user #nodetool cfstats tests | grep "Memtable switch count" Memtable switch count: 12 Where as when I try to run same command as another user it gives different result. #su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Discussion started by: Pushpraj
10 Replies

2. UNIX for Dummies Questions & Answers

Bash - CLI - grep - Passing result to grep through pipe

Hello. I want to get all modules which are loaded and which name are exactly 2 characters long and not more than 2 characters and begin with "nv" lsmod | (e)grep '^nv???????????? I want to get all modules which are loaded and which name begin with "nv" and are 2 to 7 characters long ... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Solaris

grep result in newline

Hi While trying to do a search on solaris, the grep results seems to be appearing on the same line instead of the new line. Wed Jan 18 14:45:48 weblogic@test:/abcd$ grep qainejb02 * qa_cluster_biz_view_tc_intl_servers_ports_2:qainejb02 7101 qa_cluster_servers_2:qainejb02... (2 Replies)
Discussion started by: ganga.dharan
2 Replies

4. Shell Programming and Scripting

If the grep command returns any result set

my intension is to use a grep command inside the shell script and if any row is returned or not.. depending on the resultset i have to code on further. how to check this i mean.. could anyone help me out with the if condition how to use it here !! (4 Replies)
Discussion started by: gotam
4 Replies

5. Shell Programming and Scripting

pipe result from grep

Trying to create a command line script to look for all files matching a pattern, grep for a specific value in each file, and write out the filename long list. It's possible the filename won't containe the value. { echo “Running....” for fname in 811_Intermediate_File_* do grep -l... (3 Replies)
Discussion started by: gavineq
3 Replies

6. Shell Programming and Scripting

Use grep result to execute next command

Hi I am trying to run 2 servers using a script one after the other. I start the first one: run.sh -c servername >> jboss_log.txt & Then I have to wait until I see Started message in the log file before I launch the other server. I can't use sleep because I am not sure how long it'll... (5 Replies)
Discussion started by: iririr
5 Replies

7. Shell Programming and Scripting

How to negate grep result?

Here is my script so far: set dirs = ` find . -name "message.jar" 2> /dev/null | cut -d "/" -f 2 ` | uniq foreach dir ( $dirs ) if (grep $dir/* someText==null) --> how do I write this in script? print $dir end end (4 Replies)
Discussion started by: mmdawg
4 Replies

8. Shell Programming and Scripting

diaplaying the grep result

Hi, My code is like this if swlist -a revision 2>/dev/null | grep ABC 2>/dev/null then echo "Found Above mentioned ABC Version, please remove it first..." fi This is displaying the result to the screen. i want to first suppress that and for that i wrote the below... (1 Reply)
Discussion started by: rag84dec
1 Replies

9. Shell Programming and Scripting

assign subst|grep|sed command result to a variable

Hi, I'm quite new to scripting and I want to modify following line of an existing script: MYVAR=`subst |grep 'L:\\\:' | sed -e 's/.*\\\//'`; What I have to do is to use the content of a variable instead of the constant expression 'L:\\\:' as the grep string to be matched. Assuming I already... (5 Replies)
Discussion started by: snowbiker99
5 Replies

10. UNIX for Dummies Questions & Answers

To have a numeric result from grep

I am new to unix. i need to know how to use grep to grep and expression from a file. and pass the result as a 0 for found and 1 for not found. I can only go up to grep 'Checking Subscription Status' ranos.log. Please help. Thank you. (2 Replies)
Discussion started by: Hak Dee
2 Replies
Login or Register to Ask a Question