To be honest i don't understand what you intend the sed's to do. What they actually do is to reduce the file to its first line. A "head -1" would do the same, no?
Further, there is a problem when you try to expand variables which contain blanks, because blanks are special to the shell: they separate "fields", individual parts of the input line. I will show this in an example, which actually happened in a shipped version of AIX (see the full story here):
First a word of caution: create a separate directory for this to try it out, you will see why.
Suppose you want to redirect the output of a process to a file and you want to be flexible about it, so you put it into a variable: instead of
command > file
you write in your script:
destination="file"
command > "$destination"
This will work perfectly and as expected. (When you try this replace "command" with any UNIX command - "ls -l" will do, for instance.) But now suppose you want to include the error channel in your redirect too and you do it this way:
destination="file 2>&1"
command > "$destination"
What will happen? For the shell, the content of "$destination" is one word and it will redirect only the <stdout> - [i]but to a file named "file 2>&1". (This is why i told you to create a separate directory for this - you can easily remove this directory instead of having to find out how to delete files with special characters.)
How this might function? There are two possible solutions: first, create your variables so that the blanks are outside:
dest_out="file"
dest_err="&1"
command > "$dest_out" 2>"$dest_err"
Second possibility: use "eval". The reason why the shell has problems is that it parses the lines in a fixed procedure. When variables are expanded, they are all expanded together and no second pass is given to them (this is why it isn't possible to have a variable point to another variable with "normal" means). But "eval" restarts this evaluation process and this makes the shell "reconsider" the line with the now expanded blanks in it:
destination="file 2>&1"
eval command > "$destination"
Btw.: you should really REALLY stay away from the backticks. They are only supported for backwards compatibility reasons and their use is discouraged. Only use the subshell "$(...)".
I hope this helps.
bakunin