Fixed quoting and variable expansion with sed commands