Recursivley search files and replace the characters
I have 2 sample config file under directory structure /tmp/test where variables are recognize by [].
So the task is, recursilvely go thru parent dir /tmp/test and find out the files with names *.cnf having placeholders for variables.
it's not necessary that all .cnf files got placeholders.
let's say
so it will only list /tmp/test/confa/1st_FILE.cnf and /tmp/test/confb/2nd_FILE.cnf where placeholders are there.
not /tmp/test/confa/3rd_FILE.cnf ,
Then it will go each file one by one and replace each place holder to the actual ones based on file /tmp/test/variable.txt
e.g.
after replacement final look should look like
I know, how to find the files recursively that matches [].
but my question is how can I bind variables from variable.txt to the filename that matched.
--> this will display the files with []
now how can I loop these files with variable.txt and replace the variables with actual values.
any ideas????
Last edited by manas_ranjan; 11-14-2014 at 09:17 AM..
This is my result with above snippet and samples:
The problem is awk regards "[" and "]" as special chars to build a regex. You need to somehow persuade it to accept the escaped "[" and "]".
---------- Post updated at 16:45 ---------- Previous update was at 16:43 ----------
We are getting extended Ascii characters in the input file and my requirement is to search and replace them with a space. I am using the following command
LANG=C sed -e 's// /g'
It is doing a good job, but in some cases it is replacing the extended characters with two spaces. So my input... (12 Replies)
Hi,
I am looking for any script which can do the following.
have to read a pattern from fileA and copy it to fileB.
fileA:
...
...
Header
...
...
..p1
...
...
fileB:
....
....
Header (3 Replies)
I have 100 files, where i want to search a set of strings and make the replacement by other strings
In the first case I want to include a parameter in the name of a file
LOG_DCT = $ LOG_DIR/DCT_GERAL_"$DATAINI".log
replace to : LOG_DCT = $ LOG_DIR / DCT_GERAL_ $ 1_ "$ DATAINI". log
I did... (1 Reply)
Hi all-
I've got 2 files: One is the final results and one is a result set from a query.
In the final results files I have placeholder strings in there that need to be replaced by the corresponding strings from the query file.
So File#1 (FINAL RESULTS)
LINEID CLIENT ID REP ... (1 Reply)
I have lines like:
Dog Cat House Mouse
Dog Cat House Mouse
Dog Cat House Mouse
Dog Cat House Mouse
I'd like to replace characters only in $3.
H -> Z
s -> W
e -> x
Resulting in something like (where $1, $2, and $4 are not changed):
Dog Cat ZouWx Mouse
Dog Cat ZouWx Mouse... (3 Replies)
Hi,
I am new to unix and looking out for some help in reading a file contents and replacing the characters, the requirement is I having a folder and having nearly 300 txt files, all the file contents contains some words we need to iterate all each and every files and need to find and replace it... (1 Reply)
Hi ,
I have special character control M in many of my files as below
ersNet-Telnet-3.03/Makefile.PL100644 21166 144 612 7113770214 135
77 0ustar jayusers## -*- Perl -*-^M
^M
use ExtUtils::MakeMaker qw(WriteMakefile);^M
^M
WriteMakefile(NAME => "Net::Telnet",^M
... (4 Replies)
I need to check ftp'd incoming files for characters that are not alphanumeric,<tab>, <cr>, or <lf> characters. Each file would have 10-20,000 line with up to 3,000 characters per line. Should I use awk, sed, or grep and what would the command look like to do such a search? Thanks much to anyone... (2 Replies)