Operating System - HP-UX
1752786 Members
6132 Online
108789 Solutions
New Discussion юеВ

Appending the file contents to a ksh variable (HP-UX)

 
SOLVED
Go to solution
Daavid Turnbull
Frequent Advisor

Appending the file contents to a ksh variable (HP-UX)

I tried appending the contents of a file to a variable (fred) and got some odd results.

Is this supported?

Below is a copy and past from my command line:
_________

daavid> fred="testing one two three"
daavid> echo $fred
testing one two three
daavid> fred="$fred `cat messages.config`"
daavid> echo $fred
critical 414wo three SourceID 25
daavid> cat messages.config
SourceID 25
warning 411
critical 414daavid>
Behold the turtle for he makes not progress unless he pokes his head out.
5 REPLIES 5
Muthukumar_5
Honored Contributor
Solution

Re: Appending the file contents to a ksh variable (HP-UX)

I have tried but it is working normally on 11.00?

what is ur o/s ? uname -a
Easy to suggest when don't know about the problem!
Daavid Turnbull
Frequent Advisor

Re: Appending the file contents to a ksh variable (HP-UX)

HP-UX ausccm1 B.11.00 U 9000/800 131901527 unlimited-user license
Behold the turtle for he makes not progress unless he pokes his head out.
Biswajit Tripathy
Honored Contributor

Re: Appending the file contents to a ksh variable (HP-UX)

Sure it is supported. The result should be following:

# echo $fred
testing one two three SourceID 25 warning 411

- Biswajit
:-)
Daavid Turnbull
Frequent Advisor

Re: Appending the file contents to a ksh variable (HP-UX)

Ok - I tried it again and it worked as expected. Why I got the earlier result icoonanoo?? Out of curiosity I will keep the thread open a bit and I have attached the full transcript of the session, typos and all. Also excuse my double prompt though I correct this for clarity in the final example.
___________

daavid > echo "This is from a file" > file.tmp
daavid > fred="Testing variable fred"
daavid > echo $fred
Testing variable fred
daavid > cat file.tmp
This is from a file
daavid > fred="$fred `catfile.tmp`"
ksh: catfile.tmp: not found
daavid > fred="$fred `cat file.tmp`"
daavid > echo $fred
Testing variable fred This is from a file
Behold the turtle for he makes not progress unless he pokes his head out.
Daavid Turnbull
Frequent Advisor

Re: Appending the file contents to a ksh variable (HP-UX)

Well I guess it will just go down as one of those things :-/
Behold the turtle for he makes not progress unless he pokes his head out.