SDiff Two files with space problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SDiff Two files with space problem
# 1  
Old 09-15-2014
SDiff Two files with space problem

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.

Code:
sdiff "test file1" "test file2" > Outputfile

I get this message:
Code:
        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
# 2  
Old 09-15-2014
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
# 3  
Old 09-15-2014
Hey,

I'm using for example this input:

test file1
Code:
testfile1
test3
testfile1
test3
testfile1
test3
testfile1
test3
test3
test3
testfile1

testfile1
test3

test file2
Code:
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:
Code:
 sdiff testfile1 testfile2 > Output/outputTestFiles

I get this result:
Code:
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:
Code:
sdiff "test file1" "test file2" > Output/outputTestFilesSpaces

I get this output:
Code:
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:

Code:
        usage: diff [ -C n ] [ -S name ] [ -bcefhilnrstw ] dir1 dir2
                diff [-C n ] [ -bcefhintw ] file1 file2
                diff [ -D string ] [ -biw ] file1 file2

# 4  
Old 09-15-2014
I guess you are talking of fileNAMES containing spaces? Please use the set -vx options, rerun the command and post the result.
# 5  
Old 09-15-2014
Yes, I'm talking about filenames. Sry that I didn't mentioned it.

Here's the output:

Code:
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

# 6  
Old 09-15-2014
The quotes are gone, so sdiff sees 4 parameters. Try using single quotes ( ' ).
# 7  
Old 09-15-2014
Sry tested this already.

Code:
$ 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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sdiff

file1: USER:XACME\cn3937 User:XACME\z01220 User:XACME\z01404 User:XACME\z02102 User:XACME\U17234 File2: USER:XACME\lawson USER:XACME\cn7913 USER:XACME\cn8037 USER:XACME\cn8042 USER:XACME\cn8046 USER:XACME\u31645 USER:XACME\u19050 USER:XACME\U28715 USER:XACME\U17234 USER:XACME\cn3937... (2 Replies)
Discussion started by: loktamann
2 Replies

2. Shell Programming and Scripting

Compare 2 files using sdiff command output

Hi All, I have written the shell script which does the following : a. Reads the *.cnf file content from the specified input folder path b. Grep's some strings from the *.cnf file and writes the output in result file(*.cnf_result.txt) in output folder c. Now, if we get new version of... (5 Replies)
Discussion started by: Optimus81
5 Replies

3. Shell Programming and Scripting

Script to compare files recursively using sdiff

Hi All, I have been surfing to get some idea on how to compare same files from two different paths. one path will have oldfiles directory and another path will have newfiles directory. Each main directories will have sub-directories in them and each sub-directories inturn will have... (3 Replies)
Discussion started by: Optimus81
3 Replies

4. Shell Programming and Scripting

Using sdiff without files

Hi, I'm trying to use sdiff by parsing the output of another command instead of the filename: sdiff <(echo test1) <(echo test2)However, this seems to cause my terminal session to stop working. If I use it with normal diff it works fine: ~$ diff <(echo test1) <(echo test2) 1c1 < test1... (4 Replies)
Discussion started by: Subbeh
4 Replies

5. HP-UX

Problem running out of space by copying files to identical filesystems

I am trying to copy a filesystem from one server to another using rsync over the WAN. As far as I can tell, the two filesystems are identical but for some reason I cannot copy the last file because I keep running out of space. SERVER 1: mkfs -m <lvol> mkfs -F vxfs -o... (1 Reply)
Discussion started by: keelba
1 Replies

6. UNIX for Dummies Questions & Answers

A more intelligent SDIFF

Hi all I have two files which are essentially the same. However the way an exponent is written is different (i.e. in 1 file, a particular number might be written as 1.43230000E+02 whereas in another it might be 1.4323E2). If I use SDIFF then the program will merely check the ASCII characters... (1 Reply)
Discussion started by: robbiegregg
1 Replies

7. UNIX for Dummies Questions & Answers

Space problem in files

Hi, I have a file containing a list of entries. Want to do ls on them. for a in `cat <list.txt>`; do ls $a; done; Now some entries contain spaces. How do i incorporate space in $a. Quoting $a in "" doesn't help. Thanks (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

8. UNIX for Dummies Questions & Answers

Sdiff ? problem

Hello, I'm using Sdiff to compare 2 files, I've used this before and it works fine and still does in some cases. But it seems to trip up when using combinations of alpha-numeric text. I created two simple files to test and as you can see it seems to trip up on the "gr55a" text, any ideas ? ... (2 Replies)
Discussion started by: cowpoke
2 Replies

9. UNIX for Dummies Questions & Answers

when I try to run rm on multiple files I have problem to delete files with space

Hello when I try to run rm on multiple files I have problem to delete files with space. I have this command : find . -name "*.cmd" | xargs \rm -f it doing the work fine but when it comes across files with spaces like : "my foo file.cmd" it refuse to delete it why? (1 Reply)
Discussion started by: umen
1 Replies

10. Shell Programming and Scripting

sdiff problem

Hi, I'm having the following problem with the unix sdiff command. for example if I try sdiff <filename 1> <filename 2> Where filename 1 and filename 2 contain really long pathnames that I need to compare. The output I get will be 139 characters long which is the default. But an output of... (0 Replies)
Discussion started by: ruudrio
0 Replies
Login or Register to Ask a Question