The sed command for writing is w. Using this command, we can write lines from one file to another file.
Here is an example:
$ cat new.txt
The output is as follows:
new is a empty file $ sed -n '/Chicken/w new.txt' shopping.txt $ cat new.txt Chicken 3 5 15
After the w command, we specify the file to which we will perform the write operation. In this example, the line containing the Chicken pattern is written to the new.txt file.