I have a file with iostat information about my disk in one line, but the time stay at the above line. When I use grep I can collect these two lines. But I want to put or replace the time in the same line of the disk informations.
grep -E "sda|22-09" iostat.dat
22-09-2015 15:36:10
sda 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00
22-09-2015 15:36:12
sda 0,00 2,00 0,50 17,00 0,00 0,07 8,91 0,13 7,20 0,00 7,41 5,94 10,40
22-09-2015 15:36:14
sda 0,00 10,50 0,00 3,00 0,00 0,06 38,67 0,07 24,00 0,00 24,00 24,00 7,20
22-09-2015 15:36:16
sda 0,00 5,00 0,00 5,50 0,00 0,03 12,36 0,10 18,55 0,00 18,55 18,55 10,20
要加入连续的行,请使用paste
:
grep -E "sda|22-09" iostat.dat | paste - -
Append this with GNU sed:
| sed 'N;s/\n/ /'
Output:
22-09-2015 15:36:10 sda 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 0,00 22-09-2015 15:36:12 sda 0,00 2,00 0,50 17,00 0,00 0,07 8,91 0,13 7,20 0,00 7,41 5,94 10,40 22-09-2015 15:36:14 sda 0,00 10,50 0,00 3,00 0,00 0,06 38,67 0,07 24,00 0,00 24,00 24,00 7,20 22-09-2015 15:36:16 sda 0,00 5,00 0,00 5,50 0,00 0,03 12,36 0,10 18,55 0,00 18,55 18,55 10,20
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.