sed quick reference

Continuing on this idea of quick references[1] to aid my memory, the next one is
sed: stream editor for filtering and transforming text

My favourite busybox toolkit contains sed too.

"-i" to edit files in place. Test first without this option.

'1d'delete 1st line
'5d'delete 5th line
'1,5d'delete lines 1 to 5
'1d;5d'delete lines 1 and 5
'$d'delete last line
 
'/pattern/d'delete all lines containing pattern
'/pattern/!d'delete all lines not containing pattern
 
'/^$/d'delete all empty lines


[1] vi quick reference

No comments:

Post a Comment

most viewed