小编Dyl*_*ett的帖子

Print 2nd and 7th lines to a file using `sed`

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)

sed text-processing

1
推荐指数
1
解决办法
5866
查看次数

标签 统计

sed ×1

text-processing ×1