Hello guys,
I have a problem. I'm trying to use SDiff with two files which are containing spaces.
My problem is that I want to save the output with > in an extra file.
If I try to use it like this.
sdiff "test file1" "test file2" > Outputfile
I get this message:
usage: diff [ -C n ] [ -S name ] [ -bcefhilnrstw ] dir1 dir2
diff [-C n ] [ -bcefhintw ] file1 file2
diff [ -D string ] [ -biw ] file1 file2
The output file get created and filled with the data of the two given files but I don't have the symbols which are marking changes...
Files without spaces are working fine.
Thanks in advance
Mariopart
Hello Mariopart,
Welcome to the forum, could you please let us know your input data so that we can help you in same. Also kindly use code tags for data, codes and commands as per forum rules.
Thanks,
R. Singh
Hey,
I'm using for example this input:
test file1
testfile1
test3
testfile1
test3
testfile1
test3
testfile1
test3
test3
test3
testfile1
testfile1
test3
test file2
testfile2
test3
testfile2
testfile2
test3
testfile2
test3
test3
test3
testfile2
test3
testfile2
test3
So if i'm using this command with the same file data but without spaces:
sdiff testfile1 testfile2 > Output/outputTestFiles
I get this result:
testfile1 | testfile2
test3 test3
testfile1 | testfile2
>
> testfile2
test3 test3
testfile1 | testfile2
test3 test3
testfile1 <
test3 test3
test3 test3
> testfile2
test3 test3
testfile1 | testfile2
<
testfile1 <
test3 test3
But if I'm using this command with spaces in filenames:
sdiff "test file1" "test file2" > Output/outputTestFilesSpaces
I get this output:
testfile1 testfile2
test3 test3
testfile1 testfile2
test3
testfile1 testfile2
test3 test3
testfile1 testfile2
test3 test3
test3 test3
test3 test3
testfile1 testfile2
testfile1 testfile2
test3 test3
So as you can see the symbols are missing because I get this message:
usage: diff [ -C n ] [ -S name ] [ -bcefhilnrstw ] dir1 dir2
diff [-C n ] [ -bcefhintw ] file1 file2
diff [ -D string ] [ -biw ] file1 file2
RudiC
September 15, 2014, 2:19am
4
I guess you are talking of fileNAMES containing spaces? Please use the set -vx
options, rerun the command and post the result.
Yes, I'm talking about filenames. Sry that I didn't mentioned it.
Here's the output:
sdiff "test file1" "test file2" > Output/outputTestFilesSpaces
+ sdiff test file1 test file2
+ 1> Output/outputTestFilesSpaces
usage: diff [ -C n ] [ -S name ] [ -bcefhilnrstw ] dir1 dir2
diff [-C n ] [ -bcefhintw ] file1 file2
diff [ -D string ] [ -biw ] file1 file2
RudiC
September 15, 2014, 2:31am
6
The quotes are gone, so sdiff sees 4 parameters. Try using single quotes ( ' ).
Sry tested this already.
$ sdiff 'test file1' 'test file2' > Output/outputTestFilesSpaces
sdiff 'test file1' 'test file2' > Output/outputTestFilesSpaces
+ sdiff test file1 test file2
+ 1> Output/outputTestFilesSpaces
usage: diff [ -C n ] [ -S name ] [ -bcefhilnrstw ] dir1 dir2
diff [-C n ] [ -bcefhintw ] file1 file2
diff [ -D string ] [ -biw ] file1 file2
Apparently sdiff
on your system is a shell script that is acting as a front end to diff
and it is not properly quoting the operands it is getting when it passes them on to diff
.
You can either fix sdiff
or you can rename (or make links to) the files with whitespace characters in their names to files that don't have whitespace characters in their names and use the new names as operands to sdiff
.
RudiC
September 15, 2014, 2:40am
9
Try test\ file1
etc. What OS / shell is this?
1 Like
@Don Cragun
Yeah already thought about it.
I will maybe create a temp file with the same filename and data but without spaces to use it with sdiff.
@RudiC
I'm using HPUX V11 with ksh.
Just for the fun of it, you might want to try:
sdiff 'test\ file1' 'test\ file2' > Output/outputTestFilesSpaces
The single quotes will keep ksh
from throwing away the backslashes when it gives them to sdiff
and the shell running sdiff
may then use test\ file1
and test\ file2
when invoking diff
. Without looking at the sdiff
script, there is no guarantee that this will work.
You should also check HP's maintenance sites to see if there is a patch for this; and, if not, file a bug report to get it fixed.
Good luck.
1 Like
Nope that does also not work.
$ sdiff 'test\ file1' 'test\ file2' > Output/outputTestFilesSpaces
sdiff: Cannot open: test\ file1
But thanks for your effort.