0

grep might not be the solution to what I need. I'm trying to grab the MB/s info from this command dd if=/dev/zero of=tempfile bs=1M count=1024 which returns the following information 1024+0 records in 1024+0 records out xamount bytes(1.1GB) copied, 11.234 s, 30.5 MB/s

what I tried was dd if=/dev/zero of=tempfile bs=1M count=1024|grep -oP '.....MB/s but I'm fairly new to the grep command and I'm sure I'm doing it wrong. also this is on centOS

Wes
  • 101

2 Answers2

1

If you want to grab the part containing the number and MB/s (or GB/s), you could use

dd if=/dev/zero of=tempfile bs=1M count=1024 2>&1 | grep -o '[0-9.]\+ .B/s$'

You need to redirect stderr to stdout, because dd writes this information to stderr.

Freddy
  • 25,565
0

with awk

dd if=/dev/zero of=tempfile bs=1M count=1024 |awk 'END{print $(NF-1)" "$NF}'