Sed remove matching lines script

2019-08-11 05:40发布

I'm requesting help with a very simple script...

#!/usr/bin/sed -f

sed '/11,yahoo/d'
sed '/2506,stackover flow/d'
sed '/2536,reddit/d'

Just need it to remove three matches that account for 18408 in my file, data.csv

% sed -f remove.sed < data.csv 
sed: 3: remove.sed: unterminated substitute pattern

Doing these same lines individually is no problem at all, so what am I doing wrong with this?

Using freeBSD 10.1 and its implementation of sed, if that matters.

标签: sed bsd
1条回答
聊天终结者
2楼-- · 2019-08-11 06:11

This, being a sed script, should not have "sed" at each line.

Either change it to:

#!/usr/bin/sed -f

/11,yahoo/d
/2506,stackover flow/d
/2536,reddit/d

Or to

#!/bin/sh

sed -e /11,yahoo/d \
-e /2506,stackover flow/d \
-e /2536,reddit/d
查看更多
登录 后发表回答