Article 4RV0N Using $f variables with the command sed

Using $f variables with the command sed

by
Drosera_capensis
from LinuxQuestions.org on (#4RV0N)
Hello, I am familiarizing with the concept of variable, and I don't understand how to integrate one of them in a command.

In this specific case, I am searching to extract lines from a file.
The basic command to extract the 7th line is working fine.

Quote:
sed '7!d' file
Therefore, I have made a loop to extract every seventh lines of a document (for n occurrences).

Quote:
for sample in {1..n};
do
echo $sample;
line=$((sample*7));
sed '$line!d' file ;
done
I got an error message:

Quote:
sed: -e expression #1, char 3: extra characters after command
And I do not find the answer to my problem consulting webpages, or I just do not understand the answers.

Would you have an idea why the sed command is not working with the '$line!d' variable?

Thanks for the help!latest?d=yIl2AUoC8zA latest?i=rrT4odIMcRA:8vS_NQpiPNY:F7zBnMy latest?i=rrT4odIMcRA:8vS_NQpiPNY:V_sGLiP latest?d=qj6IDK7rITs latest?i=rrT4odIMcRA:8vS_NQpiPNY:gIN9vFwrrT4odIMcRA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments