Skip to main content
1 of 6
guest_7
  • 5.8k
  • 1
  • 8
  • 13

Just place an echo before your sed command to see where n why you are going wrong.

One way to go is:

# assuming default IFS
list="2 5 7 10"
for i in $list;do
  echo "${i}p"
done | sed -nf - longText.txt
guest_7
  • 5.8k
  • 1
  • 8
  • 13