943,958 Members | Top Members by Rank

Ad:
Nov 13th, 2008
0

diff files script

Expand Post »
trying to diff new files in a dir

cd ${PWD}
for line in $(ls *.new)
     do
            # lists all new files and then 2nd variable strips the .new extension of the files
            echo ${line} ${line} | sed 's/\(.*\)..../\1/'
            diff ${line} ${line} | sed 's/\(.*\)..../\1/' 
	# this doesnt seem to work
             
# tried this way and still not working
        file1 = ${line}
        file2 = ${line} | sed 's/\(.*\)..../\1/'
        diff ${file1} ${file2}


collabrpt_cslbos.new collabrpt_cslbos
diffusql[7]: file1:  not found
diffusql[8]: file2:  not found
diff: two filename arguments required
dam.usql.new dam.usql
diffusql[7]: file1:  not found
diffusql[8]: file2:  not found
diff: two filename arguments required
Similar Threads
axn
Reputation Points: 10
Solved Threads: 0
Light Poster
axn is offline Offline
39 posts
since Sep 2007
Nov 13th, 2008
0

Re: diff files script

Looks like you need to enclose your $line|sed in both cases! Try this:

Shell Scripting Syntax (Toggle Plain Text)
  1. for line in $(ls *.new); do
  2. file1="${line}"
  3. file2="$(echo ${line} | sed 's/\(.*\)..../\1/')"
  4. diff ${file1} ${file2}
  5. done

Hope it helps!
-G
Reputation Points: 46
Solved Threads: 28
Junior Poster
Gromit is offline Offline
183 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Need help in shell scripting
Next Thread in Shell Scripting Forum Timeline: wildcarding paths





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC