I've been trying to figure out how to copy lines from one file to the end of another using sed with some shell variables.
sed -n "$var1,$var2'p'" file1.txt > file2.txt
I've tried that and many close variations but no cigar. Could someone please enlighten me about the correct syntax? Thanks.
EDIT
So I tried to suggestions below but now I get this error
sed: -e expression #1, char 2: invalid usage of line address 0
sed: -e expression #1, char 2: unknown command: `*'"
EDIT
Ok these suggestions helped and I found another issue and now my script is running flawlessly. Thank you so much!
> file2.txt
will overwritefile2
: if you want to append the copied lines to the end of the file, use>> file2.txt