
May 24th, 2012, 01:14 PM
|
Registered User
|
|
Join Date: May 2012
Posts: 3
Time spent in forums: 1 h 16 m 20 sec
Reputation Power: 0
|
|
Putting variables in the sed command in vim
I've just started using Linux and vim, and I'm pretty new to programming in general. I'm trying to write a program in vim that writes certain lines of one file to another file, and I'm trying to use a while loop and the sed command. It looks like this:
#bin/bash
sed -n '10w file2' file1
x=11
while [ $x -lt 100 ]; do
sed -n '$xw file2' file1
x=$((x + 44))
done
When I run the program it gives me this message:
sed: -e expression #1, char 3: extra characters after command
sed: -e expression #1, char 3: extra characters after command
sed: -e expression #1, char 3: extra characters after command
I tried putting the variable in double quotes, "$x" but that did not work. How can I make the sed command recognize that it is a variable?
|