Try this:
Code:
sed -ne '/sda/s/^.* \([[:digit:]]\{2,\}\) GB.*/Drive 1 \1/p' /tmp/drives.txt >>/tmp/mynewfile.txt
sed -ne '/sdb/s/^.* \([[:digit:]]\{2,\}\) GB.*/Drive 2 \1/p' /tmp/drives.txt >>/tmp/mynewfile.txt
The leading
/sda/ and
/sdb/ are addresses--they mean the s command does not take effect unless the address matches.
The -n switch causes nothing to be printed unless a 'p' flag takes affect (added at the end), which it doesn't unless the address matches.
Recent comments
14 hours 47 min ago
19 hours 52 min ago
1 day 17 min ago
1 day 2 hours ago
1 day 16 hours ago
1 day 16 hours ago
1 day 21 hours ago
2 days 4 hours ago
2 days 4 hours ago
2 days 6 hours ago