I am comparing two files. I am trying to ignore the alphanumeric characters after @
and before [
. A line looks like
model.Field@d6b0d6b[fieldName
I am comparing two files. I am trying to ignore the alphanumeric characters after
|
||||
show 2 more comments |
I assume you are using Bash. if
You can use "$new_v" or "$new_v1" depends on whether you want the @ and [ or not. As Mr. Wijsman commented, my answer doesn't answer the question. Correct, I did not pay much attention to the title. Let's fix it and wrap the code above with the following function to print a single file's data as required
Now, we can
Here is a Sample output
As you can see, the fact that the lines are different between @ and [ is being ignored, and the only line which is different between the files is this: model.FieldIAMDIFFERENTfieldName I'm sorry for not paying careful attention to your title as a part of the question. |
|||||
|
Filter the datafiles - then perform diff-:
An alternative is to use
|
|||||||||||
|
I would use process substitutions here:
|
|||||||||
|
sed
to remove everything between the@
and[
characters? If that's the case, you can pipe the output to temporary files, usediff
, and then know where your changes are. Kind of round-about, but works. Alternatively, you could use Perl. – kmort Apr 18 at 15:48s///
operator to replace everything between@
and[
with nothing, and compare the two lines with them//
operator. This becomes very complicated very quickly if your data is not VERY similar. (Like if you had to re-syncronize lines.) It's probably easiest for a one-shot deal to just do what I suggested above or what @suspectus suggested below (they are the same thing). – kmort Apr 18 at 17:25sed
command is interpreting your unescaped square bracket as the start of a character class. Put\[
instead of[
. Take a look at gnu.org/software/sed/manual/html_node/Regular-Expressions.html – kmort Apr 18 at 20:05