Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to compare two files:
Basically I have an input file fileA.
which need to be compare with fileb located in /etc/lc/mbd directroyBoth file format is like:
abc01def:10.80.11.123
The input file format is:
abc01mns:10.80.11.1
dbc02mns:10.80.11.2
fbc01mns:10.80.11.3
rbc01mns:10.80.11.4
tbc01mps:10.80.11.5
abt05mns:10.80.11.6
zbc11mys:10.80.11.7
ttc01mns:10.80.11.8
hbc05mns:10.80.11.9
qbc01mns:10.80.11.10So after comparison the script will say:
what has been dupicate and what not duplicate.Thanks

I made something but I'm not sure if it's what you want.
For example if your fileA has
A
B
C
F
Zand the fileB has
A
B
F
ythe duplicates would be A, B, F
but for the differences do you want what is in fileA but not fileB or the other way? That bit of info would be of great help.
---------
EDITI think I have something for you
---------
@echo off
setlocal EnableDelayedExpansionset f1=H:\test\fileA.txt
set f2=H:\test\fileB.txt
set dupout=H:\test\duplicate.txt
set uniout=H:\test\unique.txtfor /f "usebackq tokens=* %%a in ("%f1%") do (
set dif=2
for /f "usebackq tokens=* %%b in ("%f2%") do (
if %%a==%%b (
@echo %%a>>%dupout%
set dif=1
)
)
if !dif!==2 echo %%a >> %uniout%
)
echo unique to %f1% >> %uniout%
pause
---------set f1 to the input file
set f2 to the file you wish to compare to
set dupout to the file where duplicate entries will be listed
set uniout to the file where entries unique to f1 will be listededited script to work with file paths that contain spaces, I love Judago for teaching me how to do that.

basically the output would tell me what not match between file1 and file2. As I mentioned earlier both file formats are same"
abc01mns:10.80.11.1
dbc02mns:10.80.11.2
fbc01mns:10.80.11.3
I tried the code you have sent me but NO LUCK.$ ./Comp2FileA
./Comp2FileA: @echo: not found
./Comp2FileA[2]: setlocal: not found
./Comp2FileA[9]: syntax error at line 11 : `"usebackq tokens=* %%a in ("%f1%") do (
set dif=2
for /f "usebackq' unexpecte

I'm guessing from what you have there you didn't put the exact path of the file in the script.
Could you post what you have for the script, that would help greatly.

Here what I have :
@echo off
setlocal EnableDelayedExpansionset f1=fileA
set f2= /export/hm/dbpd.db
set dupout=duplicate.txt
set uniout=unique.txtfor /f "usebackq tokens=* %%a in ("%f1%") do (
set dif=2
for /f "usebackq tokens=* %%b in ("%f2%") do (
if %%a==%%b (
@echo %%a>>%dupout%
set dif=1
)
)
if !dif!==2 echo %%a >> %uniout%
)
echo unique to %f1% >> %uniout%
pause
##############
output with error:$ ./Comp2FileA
./Comp2FileA: @echo: not found
./Comp2FileA[2]: setlocal: not found
./Comp2FileA[9]: syntax error at line 11 : `"usebackq tokens=* %%a in ("%f1%") do (
set dif=2
for /f "usebackq' unexpected

well i solved the problem. Sorry I didn't see you are running Solaris. I wrote up a batch script for Windows.
I guess you'll have to wait till someone with Solaris know how comes along.
Sorry again

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |