I'm using sed to filter a list of files. I have a sorted list of folders and I want to get all lines after a specific one. To do this task I'm using the solution described here which works pretty well with any input I tried but it doesn't work when the match is on the first line. In that case sed will remove all lines of the input
Here it's an example:
(ssh) fabio@s2 : ~
[0] % ls -1 /
bin
boot
...
sys
tmp
usr
var
vmlinuz
(ssh) fabio@s2 : ~
[0] % ls -1 / | sed '1,/tmp/d'
usr
var
vmlinuz
(ssh) fabio@s2 : ~
[0] % ls -1 / | sed '1,/^bin$/d'
# sed will delete all lines from the input stream
How should I change the command to consider also the limit case when first line is matched by regexp?
BTW sed '1,1d'
correctly works and remove the first line only.
try this (GNU sed only):
sed '0,/^bin$/d'
..output is:
$sed '0,/^bin$/d' file boot ... sys tmp usr var vmlinuz