What I need is easy to explain but couldn't do it :-( I want to grep a command output not showing the matching lines and x lines after that. Eg.# fdisk -lDisk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesI want to skip lines with 'ram' string and 6 lines after that, so the output would be just:Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesSomething like sudo fdisk -l | grep -v ram -A 6Regards.
How to grep inverted not showing x lines before/after?
text processing;grep
Another approach with GNU sed:| sed '/ram/,/^$/d;/^$/d'Output:Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytes