Search Results

Search: Posts Made By: King Kalyan
13,984
Posted By King Kalyan
Did you check content in file3 because I...
Did you check content in file3 because I redirected output to file 3?
I tested the code with the inputs you have given and I could match your output also..

If you want the result to be printed...
13,984
Posted By King Kalyan
Try this.. awk '{ if (FNR==NR)...
Try this..

awk '{ if (FNR==NR) {arr[$1]=$0;next}
if (($1 in arr) && ($0!=arr[$1])) { f1[$1]=arr[$1]; f2[$1]=$0; next} }
END { print "from file 1"; for (i in f1) {print f1[i]}; print "from...
7,668
Posted By King Kalyan
Thanks a lot!
Thanks a lot!
7,668
Posted By King Kalyan
Hi vgersh99, I'm just going through this...
Hi vgersh99,

I'm just going through this post and having trouble understanding the code. Could you please explain the rindex function for me? I'm still learning..



Also, why did you use...
12,561
Posted By King Kalyan
Try this... awk '{ if (FNR==NR)...
Try this...


awk '{ if (FNR==NR) {arr[$0]++;next}
if ($0 in arr) { arr[$0]--; if (arr[$0] == 0) delete arr[$0]; next}
{print $0 >"newfile2"} }
END {for (i in arr) {print i >"newfile1"} } '...
16,435
Posted By King Kalyan
Thanks for giving me a new direction! I...
Thanks for giving me a new direction!

I changed the invocation because field <#KEY> can be anywhere in the file it's not always at second position. Sorry I did not mention that in my first post....
16,435
Posted By King Kalyan
Thanks Cherry! I do not know perl so this is kind...
Thanks Cherry! I do not know perl so this is kind of out of scope for me but I heard perl is very fast. I have to learn that in future.

The below awk code runs fine for small number of records...
7,028
Posted By King Kalyan
Try this.. find . -type f -name...
Try this..


find . -type f -name '*.txt' | while read file
do
echo "stripping ^M from [$file]..."
sed "s/^M//g" file > temp_file
mv -f temp_file > file
done


Note: For ^M do not...
16,435
Posted By King Kalyan
Thanks!! You are the best!! BTW Thanks for...
Thanks!! You are the best!!
BTW Thanks for calling the awk code as king.awk :cool:

This is not giving the desired results if the missing record is last one in the file 2. I figured it out, as...
16,435
Posted By King Kalyan
Perfect!! Thanks a lot!!! It works great!! I...
Perfect!! Thanks a lot!!!
It works great!! I never thought it in that angle.

I added one more part, please check and let me know if I did it right.
If there is no match for a value in file 2...
16,435
Posted By King Kalyan
Thanks for quick reponse! The code is kind...
Thanks for quick reponse!

The code is kind of suppressing duplicates and it's not giving corresponding field 2 of file 1 in the output. I need all records in the output with different field 2...
16,435
Posted By King Kalyan
Read a file and search a value in another file create third file using AWK
Hi,

I have two files with the format shown below. I need to read first field(value before comma) from file 1 and search for a record in file 2 that has the same value in the field "KEY=" and...
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 04:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy