I am executing a shell script in which I run a sybase query which gives the O/P in a file .
The Output is :-
tablename
---------------------------
result of query executed my case will be an integer returned
(Number of rows effected ).
What i want to do is read result of query executed which in my case will be an integer returned
into a variable in a shell script . It will be in 3rd line in the file in which i have redirected the Output of my Sybase Query .
How can i do that ?
To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press <Enter>. By default, head shows you the first 10 lines of a file. You can change this by typing head -number filename, where number is the number of lines you want to see.
Did you mean this?
x=`sed -n '3p' inputfile`;
echo $x;
EDIT
Do this.
thirdline=`sed -n '3p' /home/nmsad/abc.txt`;
echo $thirdline;
Try using sed
like this:
variable=$(your_script | sed -n '3 p')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With