I am not sure exactly what you are trying to do. Sed or gawk can be used to return particular values from your file, "test". If you are only going to get one such value returned (or don't care about the newlines), you can assign it to a variable as follows:
x=$(gawk ... test)
x=$(sed ... test)
where the three dots represent the appropriate options and/or script.
You can use "cut" to return particular columns or fields from a file, and if you desire, you can redirect these to a new file.
Perhaps it would be easiest if you reviewed the man pages (e.g. "man sed")
or info pages (e.g. "info sed") and see if you could formulate a more targeted question.