Kornshell grabbing value from file

I have a script right now that I run a command which outputs just one word to a file. Well I need to grab that value and use it in another line of code so...

touch oraclesid.txt
echo $ORACLE_SID > oraclesid.txt
#grab that value
sqlplus v500/v500@<value>

how do I grab that value from the file and make it a variable to use it in that last line?

---------- Post updated at 12:13 PM ---------- Previous update was at 12:05 PM ----------

Can i pipe whats in that file and turn it into a variable?

If i understand the question... Use $(<filename) like this:

$ cd /tmp
$ xval=0
$ echo 123 > xfile
$ echo $xval
0
$ xval=$(<xfile)
$ echo $xval
123
$

I need to grab <value> from file.txt
x < file.txt
so x=<value>

Then i need to use that variable in a command

sqlplus v500/v500@<x>

How do I do that?
Whats the syntax

I must not understand your requirement. I thought that did exactly that. Oh well maybe someone else can see what I missed.

I also gather that is the requirement. Perhaps this?

sqlplus v500/v500@$(cat oraclesid.txt)

This should work for ksh88 and posix shells too ( $(<xfile) is bash/ksh93 )

:confused: I just tested it on Version M-11/16/88i of ksh on solaris 8 and it worked for me.

1 Like

I stand corrected :). It is not posix but it is available in ksh88.