I have a directory of .txt files. For each, i'd like to grab the 2nd and 7th line, and add those lines to another file, which I've arbitrarily named list.index. I'm not sure how to tell sed about the current filename, within the for loop, so what I have below doesn't work yet.
#!/bin/sh
for i in *.txt
do
sed -n -e '2p' -e '7p' list.index
done
Run Code Online (Sandbox Code Playgroud)