subsitute $var

subsitute $var

Post by Terenc » Fri, 26 Jul 2002 12:39:12



Hi,

I have a file filelist.txt which has the following line:
/usr/lpp/$var/directory

In my script,
var=abc123

line=`cat filelist.txt`
echo $line

It shows /usr/lpp/$var/directory

How to make it so that i have /usr/lpp/abc123/directory ?

Thanks and regards.

 
 
 

subsitute $var

Post by Cameron Simpso » Fri, 26 Jul 2002 14:04:10



| I have a file filelist.txt which has the following line:
| /usr/lpp/$var/directory
|
| In my script,
| var=abc123
|
| line=`cat filelist.txt`
| echo $line
|
| It shows /usr/lpp/$var/directory
|
| How to make it so that i have /usr/lpp/abc123/directory ?

line=`sed "s;\$var;$var;g" filelist.txt`
echo "$line"

cheers,
--

Working for Apple is not quite the same as mugging young children for a living.


 
 
 

subsitute $var

Post by Chris F.A. Johnso » Fri, 26 Jul 2002 15:40:24



> Hi,

> I have a file filelist.txt which has the following line:
> /usr/lpp/$var/directory

> In my script,
> var=abc123

> line=`cat filelist.txt`
> echo $line

> It shows /usr/lpp/$var/directory

> How to make it so that i have /usr/lpp/abc123/directory ?

     eval echo $line

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

subsitute $var

Post by Terenc » Sun, 28 Jul 2002 12:17:41


Thanks Chris,

It works. I learn a lot from this forum.




> > Hi,

> > I have a file filelist.txt which has the following line:
> > /usr/lpp/$var/directory

> > In my script,
> > var=abc123

> > line=`cat filelist.txt`
> > echo $line

> > It shows /usr/lpp/$var/directory

> > How to make it so that i have /usr/lpp/abc123/directory ?

>      eval echo $line

> --
>     Chris F.A. Johnson                        http://cfaj.freeshell.org
>     ===================================================================
>     My code (if any) in this post is copyright 2002, Chris F.A. Johnson
>     and may be copied under the terms of the GNU General Public License

 
 
 

1. sh var -> awk var -> sh var

I want to do something like the following:
---------------------------------------------------------------------
echo "-----------end----------------"
line_num=`expr $line_num + 1`
awk '{  
       for( ; n%=xx ; n++ )  <---xx means a number.
        printf("\n")
     }' n=$page_line          <---this need input, else it stop....
line_num=$n    <-----I want $line_num = n in awk.
---------------------------------------------------------------------
I need certain length of the outfiles, so if "----end----" end at line number
which is not enough, space lines are added to enough length number.
Thanks.

--
  =====================================================================
    Simon Tneoh Chee Boon  ~{UEV>ND~}  i?

    Hsin Chu City       NATIONAL TSING HUA UNI.
    P.O.Box 2-037       Material Science Engineering Dept. Batch '96

    R.O.China.          http://140.114.63.14:6083/simon.html
    886-35-715131-7300
  =====================================================================

2. tape drive & second hard drive

3. Motif Subsitute !!!

4. DigiBoard 16 and Linux?

5. How to subsitute variables containing "/"?

6. Is there any way to mount a Windows shared folder from Solaris?

7. VI Subsitute

8. ? Setup sol7 Sparc remot print to NT Print server

9. How large can /var/log/messages and /var/log/syslog get ?

10. trimming /var/adm/messages & /var/adm/syslog

11. How to close /var/log/syslog and /var/log/messages..

12. Need help not passing make vars as env vars in gmake.

13. cd $var where var is a windows path with spaces in it