Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I used diff and sed

What I need to do is diff 2 files to check for changes. However both of these files have a certain 4 lines in them that are guaranteed to change and that I want to ignore for the diff. My idea is to use sed to remove the 4 lines using a regex which I can get to work no problem, however I must not be using the sed command right in the diff as I get the error "The system cannot find the file specified".

The sed command I'm using is:

sed "/regex1/,/regex2/ d" "filename"

This removes the 4 lines between the two regex's properly.

The diff command I'm trying is:

diff <(sed "/regex1/,/regex2/ d" "file1") <(sed "/regex1/,/regex2/ d" "file2")

and this is giving the error.

Can anybody tell me how I'm using diff wrong?

Thanks

like image 548
sineil Avatar asked Nov 25 '25 22:11

sineil


1 Answers

I didn't have problem running the command you tried.

However I could use the command

sed ... | diff - <(sed ...)

with the same results

like image 196
Nico Rodsevich Avatar answered Nov 28 '25 10:11

Nico Rodsevich