Hello!
I'm working on a script in bash, and I have 2 parameters from the user, $4 and $5. I want to delete this range of lines. This is what I have ($1 is the file we're deleting from):
Code:
touch temp
sed "$4,$5 d" > temp
mv temp $1
In theory this should create a temporary file, delete the line range and put it into the temporary file, and then replace $1 with this temporary file.
The 2nd line isn't working. When I do this with 2 normal numbers it works, but not with 2 variables containing numbers. Any ideas on how to fix this? What I end up getting is nothing written to the temporary file at all, so $1 becomes a blank file.
Although the code above doesn't work, deleting a single line like this works:
Code:
touch temp
sed "$4 d" > temp
mv temp $1
What am I missing here??