How to delete lines that do not match the pattern except the first line?
To delete lines except first i use
sed '1!d'
To delete lines that do not match patter i use
sed '/pattern/!d'
How can i use both of conditions? Things like
sed '1!/pattern/!d'
doesn't work, says unknown command: '/'
As example (if pattern="rcu") from input
PID PPID PRI NI VSZ RSS STAT TIME CMD
1 0 19 0 33664 4832 Ss 00:00:07 /sbin/init splash
2 0 19 0 0 0 S 00:00:00 [kthreadd]
3 2 39 -20 0 0 I< 00:00:00 [rcu_gp]
4 2 39 -20 0 0 I< 00:00:00 [rcu_par_gp]
8 2 39 -20 0 0 I< 00:00:00 [mm_percpu_wq]
9 2 19 0 0 0 S 00:00:04 [ksoftirqd/0]
get
PID PPID PRI NI VSZ RSS STAT TIME CMD
3 2 39 -20 0 0 I< 00:00:00 [rcu_gp]
4 2 39 -20 0 0 I< 00:00:00 [rcu_par_gp]
Thanks