Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Replace Stub Values In One Group Of Files With Actual Values From Another Group Of Files Post 303037301 by spacegoose on Monday 29th of July 2019 01:36:32 PM
Old 07-29-2019
Replace Stub Values In One Group Of Files With Actual Values From Another Group Of Files

I have two directories of files (new-config-files and old-config-files):

Code:
new-config-files/this-db/config.inc.php
new-config-files/that-db/config.inc.php
new-config-files/old-db/config.inc.php
new-config-files/new-db/config.inc.php
new-config-files/random-database/config.inc.php
etc.

old-config-files/this-db/config.inc.php
old-config-files/that-db/config.inc.php
old-config-files/old-db/config.inc.php
old-config-files/new-db/config.inc.php
old-config-files/random-database/config.inc.php
etc.

Example snippet of old file:
Code:
$cfg['Servers'][$i]['user'] = 'test-user';
$cfg['Servers'][$i]['password'] = 'test-user-password';
$cfg['Servers'][$i]['only_db'] = 'test-data';

Example snippet of new file:
Code:
$cfg['Servers'][$i]['user'] = 'DB-USER';
$cfg['Servers'][$i]['password'] = 'DB-PASSWORD';
$cfg['Servers'][$i]['only_db'] = 'DB-DATABASES';

I'd like to replace only the stub values (i.e., DB-USER, DB-PASSWORD, DB-DATABASES) in the new config files with the corresponding actual values (i.e., test-user, test-user-password, test-data) from the old config files.

It might also be good to know how to do this when there are no stub values, but only different values that should be replaced.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

2. Shell Programming and Scripting

Awk: Summing values with group criteria

Hi Guys, I have a text file with ";" like separator F1;F2;F3;F4;F5 444;100041;IT;GLOB;1800000000 444;100041;TM;GLOB;1000000000 444;10300264;IT;GLOB;2000000000 444;10300264;IT;GLOB;2500000000 I have to sum the cullums F5 for same F2 and F3 collums The result must be: ... (7 Replies)
Discussion started by: gianluca2
7 Replies

3. Shell Programming and Scripting

search file and group values with problematic tab

hi people; the similar topic is being opened in here and here but i have confused with following condition. so i wanted to open a seperate topic. from my file.txt:... ... ... 110105-16:04:04 192.168.1.1 7.1j Port_NODE_MODEL_M_1_8 stopfile=/tmp/10544... (0 Replies)
Discussion started by: gc_sw
0 Replies

4. Shell Programming and Scripting

Print lines containing same values in a group

Hi, I have a table like this: Name A1 A2 A3 B1 B2 B3 111 abc abc abc cbc cbc cbc 222 acv acv n_n bbc bbc bbc 333 bvv bvv bvv cBx ccx ccx 444 ttk ttk ttk kke kke kke 555 mcr mcr mcr mcr mcr mcr The 1st column is just names... (3 Replies)
Discussion started by: polsum
3 Replies

5. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

6. Shell Programming and Scripting

Sum up the column values group by using some field

12-11-2012,PNL,158406 12-11-2012,RISK,4564 12-11-2012,VAR_1D,310101 12-11-2012,VAR_10D,310101 12-11-2012,CB,866 12-11-2012,STR_VAR_1D,298494 12-11-2012,STR_VAR_10D,309623 09-11-2012,PNL,1024106 09-11-2012,RISK,4565 09-11-2012,VAR_1D,317211 09-11-2012,VAR_10D,317211 09-11-2012,CB,985... (7 Replies)
Discussion started by: manas_ranjan
7 Replies

7. Shell Programming and Scripting

Add the values in second and third columns with group by on first column.

Hi All, I have a pipe seperated file. I need to add the values in second and third columns with group by on first column. MYFILE_28012012_1115|47|173.90 MYFILE_28012012_1115|4|0.00 MYFILE_28012012_1115|6|22.20 MYFILE_28012012_1116|47|173.90 MYFILE_28012012_1116|4|0.00... (3 Replies)
Discussion started by: angshuman
3 Replies

8. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

9. Shell Programming and Scripting

Replace two values in a file with input from two different files

Hi, I was having the following issue cat input hello1, my name is unix.com. I am awesome. Hope you know this, hello2! cat hello1.txt Hi Friends Hi Folks Hi Well-Wishers cat hello2.txt Honey Sweety Darling Required Output (8 Replies)
Discussion started by: jacobs.smith
8 Replies

10. Shell Programming and Scripting

Replace values between 2 files

I want to replace the third and fourth lines of a 2nd file by the first two lines of a file. Input: file_1 file_1.line_1 file_1.line_2 file_2 file_2.line_1 <file_2.line_2_blank> file_2.line_3 file2.line_4 <file_2.line_5_blank> Output: file_2.line1 <file_2.line_2_blank>... (1 Reply)
Discussion started by: arpagon
1 Replies
config(8)						      System Manager's Manual							 config(8)

Name
       config - build system configuration files

Syntax
       /etc/config [-p] [-s] config_file

Description
       The  command  builds a set of system configuration files from a short file which describes the sort of system that is being configured.	It
       also takes as input a file which tells what files are needed to generate a system.  This can be augmented by a configuration  specific  set
       of files that give alternate files for a specific machine.  (See the Files section.)  If the -p option is supplied, will configure a system
       for profiling.  You must have sources to use the -p option.  Use the -s option when building a kernel from sources.

       The command should be run from the subdirectory of the system source (usually ).  The command assumes that there  is  already  a  directory
       created	and it places all its output files in there.  The output of consists of a number files: contains a description of what I/O devices
       are attached to the system, and is a file used by in building the system; a set of header files which contain the number of various devices
       that  will  be  compiled into the system; and a set of swap configuration files which contain definitions for the disk areas to be used for
       swapping, the root file system, argument processing, and system dumps.

       After running it is necessary to run in the directory where the new makefile was created.  The command reminds you of  this  when  it  com-
       pletes.

       If  you receive other error messages from fix the errors in your configuration file and try again.  If compile a system that has configura-
       tion errors, the system will fail.

Restrictions
       The line numbers reported in error messages are usually off by one.

Files
       Generic makefile

       List of common files that the system is built from

       List of machine specific files

       Name to major device mapping file

       List of known file systems

See Also
       The Syntax portion of each device in Section 4 of the ULTRIX Reference Pages
       ``Building 4.2BSD UNIX System with Config,'' ULTRIX Supplementary Documents, Volume 3: System Manager

								       RISC								 config(8)
All times are GMT -4. The time now is 06:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy