Sponsored Content
Top Forums Shell Programming and Scripting Using SED to generate new file from template Post 302338659 by ppucci on Tuesday 28th of July 2009 02:51:09 PM
Old 07-28-2009
Quote:
Originally Posted by edidataguy
Well too many things in one go.
Lets split them.
Ragarding:
Code:
 
-e "s|CUR_MGMT_INT|$CUR_MGMT_INT|g"\
-e "s|CUR_MGMT_INT|$CUR_MGMT_INT|g"\
-e "s|CUR_MGMT_IP|$CUR_MGMT_IP|g"\
-e "s|CUR_MGMT_IP|$CUR_MGMT_IP|g"\

You need not call sed again and again.
As an example, the code can be as follows:
Code:
sed \
"s|HNAME|$HNAME|;   \
 s|REGION|$REGION|;  \
 s|SITE_ID|$SITE_ID|; \
.............."

In your case you don't need the "/G". Without it, the command will run faster.
Ok, I'll give it a try without "-e" and "/g"... and for the duplicate replacements, already scraped them Smilie

---------- Post updated at 01:51 PM ---------- Previous update was at 01:43 PM ----------

tried... worked just fine... on this particular case, speed was not really an issue as the script ran for about 10 seconds or less (for a 950 records source file).

Will keep that in mind on my next scripts!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

configuration and template file

Hi, I have a configuration file(which has values) and a template file(where the values are dummied) Configuration file (a.txt) -------------------- var1=1521 var2=172.10.10.10 var3=emp . . . var15=hhhhhhh Template file (b.txt) -------------------- The host name is $var2. The... (5 Replies)
Discussion started by: ammu
5 Replies

2. Shell Programming and Scripting

sed script to generate hyperlinks refuses to work

Hi All, I'm new to the forum and not a programmer, but I'm writing a bash script to preprocess definitions of technical terms by inserting hyperlinks pointing to other pages in the glossary before the pages are posted to our server, using a standard naming convention for the pages. The... (3 Replies)
Discussion started by: markfgilliland
3 Replies

3. Shell Programming and Scripting

Reading columns, making a new file using another as template

Hi fellas, I have two files such as: File 1 interacao,AspAsp,AspCys,CysAsp,CysCys,classe File 2 interacao,AspAsp,CysAsp,AspCys,CysCys,classe beta_alfa, DA, CA, DD, CD,ppi Thus, I want to make a File 3 using the File 1 as model: e.g. File 3... (2 Replies)
Discussion started by: valente
2 Replies

4. Shell Programming and Scripting

filling in strings in a template file using awk

Hi all, I have a template form to fill in for quite a number of files and I want to automate the filling-in process. the concept seemed to be simple but i cant get it work. the template form is a text file containing the information below: File Name: Date Created: Contents: I need to... (4 Replies)
Discussion started by: ida1215
4 Replies

5. Shell Programming and Scripting

Creating a larger .xml file from a template(sample file)

Dear All, I have a template xml file like below. ....Some---Header....... <SignalPreference> ... <SignalName>STRING</SignalName> ... </SignalPreference> ......Some formatting text....... <SignalPreference> ......... ... (3 Replies)
Discussion started by: ks_reddy
3 Replies

6. UNIX for Dummies Questions & Answers

XML File Generation - Template Help

Hi, I have hit a bit of a brick wall.:confused: need the following code edited: echo "<?xml version=\"1.0\"?><dailyBalance_ROWSET>" > ${DataDir}/${extract_script}${ApplicationDate}.${Suffix} RunSQL ${extract_script} ${ActionFlag} echo "</dailyBalance_ROWSET>" >>... (2 Replies)
Discussion started by: Xergxes7
2 Replies

7. Linux

Search a template file and replace with input

Hi I have a CommonTemplateStop.template file . Inside the file i need to replace the variables DepName and CompInsName with the values(Trade and TradeIns) specified in the script. I have written the below .sh script in linux server which will read the .template file and has to replace the 2... (8 Replies)
Discussion started by: samrat dutta
8 Replies

8. Shell Programming and Scripting

Inputing info from a CSV file and filling a template file

Hi, I have a .csv file that contains a variety of fields for 60 clients: USERNAME, PASSWORD, and COMMENTS. I have a template file which contains a great deal of data for each client and has the fields USERNAME, PASSWORD, and COMMENTS that has to be filled with the values of USERNAME,... (1 Reply)
Discussion started by: mojoman
1 Replies

9. Shell Programming and Scripting

Merge strings from a file into a template

I am preparing a morphological grammar of Marathi to be placed in open-source. I have two files. The first file called Adverbs contains a whole list of words, one word per line A sample is given below: आधी इतक इतपत उलट एवढ ऐवजी कड कडनं कडल कडील कडून कडे करता करिता खाल (2 Replies)
Discussion started by: gimley
2 Replies

10. UNIX for Beginners Questions & Answers

Generate files and use csv data to replace multiple variables in a template

I have a source csv file consists of first field as variable name, and the rest are site-specific information (converted from excel file, where site -specific values in columns). I am trying to create a file for every site using a template and replace the multiple variables with values from the... (3 Replies)
Discussion started by: apalex
3 Replies
APT-EXTRACTTEMPLATE(1)							APT						    APT-EXTRACTTEMPLATE(1)

NAME
apt-extracttemplates - Utility to extract DebConf config and templates from Debian packages SYNOPSIS
apt-extracttemplates [-hv] [-t=temporary directory] file... DESCRIPTION
apt-extracttemplates will take one or more Debian package files as input and write out (to a temporary directory) all associated config scripts and template files. For each passed in package that contains config scripts and templates, one line of output will be generated in the format: package version template-file config-script template-file and config-script are written to the temporary directory specified by the -t or --tempdir (APT::ExtractTemplates::TempDir) directory, with filenames of the form package.template.XXXX and package.config.XXXX OPTIONS
All command line options may be set using the configuration file, the descriptions indicate the configuration option to set. For boolean options you can override the config file by using something like -f-,--no-f, -f=no or several other variations. -t, --tempdir Temporary directory in which to write extracted debconf template files and config scripts. Configuration Item: APT::ExtractTemplates::TempDir -h, --help Show a short usage summary. -v, --version Show the program version. -c, --config-file Configuration File; Specify a configuration file to use. The program will read the default configuration file and then this configuration file. If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf(5) for syntax information. -o, --option Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar. -o and --option can be used multiple times to set different options. SEE ALSO
apt.conf(5) DIAGNOSTICS
apt-extracttemplates returns zero on normal operation, decimal 100 on error. BUGS
APT bug page[1]. If you wish to report a bug in APT, please see /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command. AUTHORS
Jason Gunthorpe APT team NOTES
1. APT bug page http://bugs.debian.org/src:apt Linux 29 February 2004 APT-EXTRACTTEMPLATE(1)
All times are GMT -4. The time now is 10:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy