Operating System - Linux
1825813 Members
2528 Online
109688 Solutions
New Discussion

Include a File in other text file like C Programs

 
SOLVED
Go to solution
Sachin_48
Occasional Advisor

Include a File in other text file like C Programs

Hi all,

I want to include a file in other text file in linux like as we were doing while writting "C" Programms for referencing the other files.


Infact I don't want to edit my main file "A"
While I want some changes to take place because of changes in "A" . So I want one more file "B" which will be changes by me frequently and will be included in "A" .

So that the function using file "A" will work efficiently without touching the file "A".

Pls help

Sachin Rajput
HCL
4 REPLIES 4
Ivan Ferreira
Honored Contributor

Re: Include a File in other text file like C Programs

To include other files in shell scripts, you can use the "source command"

> cat fileA

# This is file A, and will source fileB
source fileB
# Now file A continues
command ...
command ...
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
spex
Honored Contributor

Re: Include a File in other text file like C Programs

Hi,

If you're talking about shell scripts, either 'source ' or '. ' (period), which is probably more commonly used, will accomplish this. Check out 'man .'.

PCS
Sachin_48
Occasional Advisor

Re: Include a File in other text file like C Programs

HI Infact what I want is

I have /etc/mail/access file and when I make it it becomes /etc/mail/access.db

But Now I want that in /etc/mail/access I will specify one line which will address to another file so that while making hash file /etc/mail/access.db

It will encrypt both /etc/mail/access and the one specified inside.

Pls Revert.


Sachin
Stuart Browne
Honored Contributor
Solution

Re: Include a File in other text file like C Programs

When making DB maps for sendmail's access, you can have multiple source files, and 'cat' them through 'makemap' to create the DB file. For example, I use this:

LCL_ACC=/etc/mail/access
LCL_FILE=/etc/mail/access.rejects
LCL_MAP=/etc/mail/access.db
cat $LCL_ACC $LCL_FILE | makemap hash $LCL_MAP

The other thing you can do (if you want to remember the original values) is just to append to the DB using:

echo | makemap -o hash $LCL_MAP

This will append '' as a DB record to the local database.

Of course, if you ever want to get a list of the addresses again, you have to use un-makemap the DB:

makemap -u hash $LCL_MAP

This lists the contents of the DB.

I hope this helps you.
One long-haired git at your service...