Bad file descriptor - error with sed

I'm learning SED command. And while doing that i got to this place where i'm taking a copy of my existing file. The code i used is -

sed -n '/Storm/ w Storm.txt' books.txt

As expected, the file 'books.txt' is read , and lines with 'Storm' is put in to the new file 'Storm.txt'. However, it also throws the below error -
sed: read error: Bad file descriptor

Can someone help me understand why is it happening.

---------- Post updated at 02:00 PM ---------- Previous update was at 01:58 PM ----------

<I'm sorry, i think i posted in wrong place. Couldn't find the right place to post from my profile. So, just googled on how to post, and ended up here.>

---------- Post updated at 02:02 PM ---------- Previous update was at 02:00 PM ----------

< I believe, i moved the thread to the right place now.>

Your sed command is a bit unusual but should work as intended.
What is your OS?

uname

The normal working with sed is with stdout. Of course it then needs an invoking shell that redirects its stdout to the output file:

sed -n '/Storm/ p' books.txt > Storm.txt
1 Like

As I'm learning these things now, i'm practicing in 'VFsync'.
This gives an online terminal to practice.
It's 'Linux'.

I tried your command, and produces same result as i got early, however without the error message.

Looks more like a deficiency of that web site, as I can replicate the error with the usually OK command given in post#1.

Ok. Thanks guys.