The slashes are part of awk syntax and not related to the directory separator character of your platform. So no, no need to change them to backslashes.
In the sed script, the file name containing the tags is supposed to be in ..\replace so yes, there, you'd perhaps change the directory separator (although I understand DOS can cope with a forward slash as well).
awk 'script in awk syntax here' file1 file2 file3 ... is how you typically invoke an awk script. On DOS you might need to use different quote marks, or simply put the script in a file and run it from there (with awk -f scriptfile.awk assuming your version of awk supports that).
The above script with sed and awk in it is a shell script, so you need /bin/sh or bash or something like that to execute it.
OK, i am REALLY lost now (I use SED for basic search/replace and AWK is a creature:
temp=`sed -n "${n}p" ../replace`
I change the ../replace with the name of the files with the IPs in it?
Lets say the files are named dns.txt and ips.txt
dns.txt = the file with the T????CLK????
ips.txt = the file with the pool of IPs to use as the substitutes
script.awk has the awk command from above in it so i would type "awk -f script.awk dns.txt ips.txt" at the command prompt?
Sorry, no. It's still a shell script. You would do something like
... and script.awk would contain the nawk script.
This is probably not directly useful, but shows where you would plug in the parts you had questions about.
The original script wanted to change all files in the current directory (that's * where now we have only dns.txt), and globally replace all occurrences of "this" in each file with a different value out of ../replace (now ips.txt), in a different directory because you were making substitutions in all files in the current directory (basically I imagine on the assumption that there is only one occurrence of "this" -- or actually T????CLK??? -- in each file, but a lot of files).
But what you seem to want is probably closer to
If there are multiple occurrences of T????CLK??? on a single line, they will both get the same value out of ips.txt -- if this is a problem, a slightly more complex script will be necessary. Also if there are more lines with matches in dns.txt than there are values in ips.txt the last ones in dns.txt will be replaced with an empty value. This is obviously not very newbie-friendly, but as long as you keep these constraints in mind, it's simple and understandable.
The output is stored in dns.new; you can move it to dns.txt when you're done. The earlier script has code for checking whether any substitutions took place, and only replacing the old file if the new file is different.
(Line wraps in the awk scripts are not significant; you can type it all on a single line if you like.)
Hi
Does anyone know of an efficient way to index a column of data in file2 to print the coresponding row in file1 which corresponds to the data in file2 AND 30 rows preceding and after the row in file1.
For example suppose you have a list of numbers in file2 (single column) as follows:... (6 Replies)
I am trying to use awk to find all the $2 values in file2 which is ~30MB and tab-delimited, that are between $2 and $3 in file1 which is ~2GB and tab-delimited.
I have just found out that I need to use $1 and $2 and $3 from file1 and $1 and $2of file2 must match $1 of file1 and be in the range... (6 Replies)
I want to print only the lines in file2 that match file1, in the same order as they appear in file 1
file1
file2
desired output:
I'm getting the lines to match
awk 'FNR==NR {a++}; FNR!=NR && a' file1 file2
but they are in sorted order, which is not what I want:
Can anyone... (4 Replies)
Dear All,
Need your help..:D
I am not regular on shell scripts..:(
I have 2 files..
Content of file1
cellRef 4};"4038_2_MTNL_KALAMBOLI"
cellRef 1020};"4112_3_RAINBOW_BLDG"
cellRef 134};"4049_2_TATA_HOSPITAL"
cellRef 1003};"4242_3_HITESH_CONSTRUCTION"
cellRef... (6 Replies)
I have file 1 & file 2 with content mentioned below. I want to get the output as shown in file3.
Requirement:
check the content of column 1 & column 2, if value of column 1 in file1 matches with first column of file2 then remaining columns(2&3) of file2 should get replaced, also if value of... (4 Replies)
Hello to all,
I hope somebody could help me with this:
I have this File1 (real has 5 million of lines):
Number Category
--------------- --------------------------------------
8734060355 3
8734060356 ... (6 Replies)
I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string.
I'm looking to match column1 in file1 to the number... (3 Replies)
Hello guys,
should be a very easy questn for you:
I need to delete strings in file1 based on the list of strings in file2.
like file2:
word1_word2_
word3_word5_
word3_word4_
word6_word7_
file1:
word1_word2_otherwords..,word3_word5_others... (7 Replies)
hi;
my file2.txt:portname=1;list=10.11;l-
portname=2;list=10.12;l-
portname=3;list=10.13;l-
...
my file1.txt:;"{'sector=%27'}"\&>
so; i want to see:portname=1;list=10.11;l-;"{'sector=%27'}"\&>
portname=2;list=10.12;l-;"{'sector=%27'}"\&>
portname=3;list=10.13;l-;"{'sector=%27'}"\&>... (4 Replies)
Hello,
I've never used awk before, but from what I've read, it will best suit what I'm trying to do. I have 2 files. I need to replace strings in file1 with the first column of a matching string in file2. Below are examples:
File1:
random-string1
1112
1232
3213
2131
random-string2... (7 Replies)