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:
Therefore, I have made a loop to extract every seventh lines of a document (for n occurrences).
Quote:
I got an error message:
Quote:
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!


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 |
Quote:
| for sample in {1..n}; do echo $sample; line=$((sample*7)); sed '$line!d' file ; done |
Quote:
| sed: -e expression #1, char 3: extra characters after command |
Would you have an idea why the sed command is not working with the '$line!d' variable?
Thanks for the help!