Quote:
Originally Posted by DeepSeaNautilus
I want to use the variable to insert
the table into another file and for that it must keep the original
newline characters.
|
The backtick operator has that "feature", if you can call it a
feature. You didn't describe what you really want to do other than
the above sentence so we are left to guess, but here is one way to get
at a particular line in a file and store it into a variable:
Code:
a=`cat fileA | grep three`
echo $a
By the way, you had $A instead of $a in your script, and that won't
work (you will get empty output from the echo because $A was not set
but $a was set.)
There is also the $() operator which works under Linux's sh and bash
shells, but does not work on all UNIX's Bourne shells. But since this
is a Linux forum, and I suspect you are on Linux, you could write the
above as:
Code:
a=$(cat fileA | grep three)
echo $a
The $(...) syntax has the advantage in that it can be nested, while
the backtick expression, `...`, can't for obvious reasons.
bg