All Questions
Tagged with diff shell-script
57 questions
-1
votes
2
answers
90
views
In bash/zsh, how to compare the metadata in two directories including . and excluding .. and the contents inside subdirectories?
Let's say that in a script, you have a directory $1 and its copy $2 and you'd like to compare the metadata (names, permissions, sizes, full modification dates, …) of the files and directories inside ...
2
votes
3
answers
393
views
How to compare two directories recursively, and for each pair of files with the same name, location, and contents, say which file is older?
In a Linux shell, how to compare two directories recursively, and for each pair of files (including symlinks and directories) with the same location (including the name) in the two directories and the ...
0
votes
0
answers
59
views
Help with creating a bash code to compare two different files
I'm currently encountering some challenges while working on a bash script in the Linux terminal to perform the following tasks:
Compare the values in the third column of two different files line by ...
2
votes
2
answers
1k
views
How to apply a patch as part of a pipe? In other words, how to patch stdin?
I want to apply a unified diff from mypatch.diff to stdin and output the result to stdout.
So far, I have tried:
patch -i mypatch.diff -o - -u originalfile
Which successfully applies mypatch.diff and ...
10
votes
1
answer
1k
views
Space not taken as an argument separator by shell script (could someone please explain that small file difference ?)
SHORT VERSION (TL;DR)
I have 2 small one-line files, seemingly identical :
$ cat f1 f2
./cconv.sh 100 EUR USD
./cconv.sh 100 EUR USD
But they are not, there is a 1 byte difference in size :
$ ls -l ...
0
votes
1
answer
1k
views
looking to compare two directories using boolean statement
just looking to compare two directories and make sure that all files reside in both, I'm aware of the diff cmd but is there a way to use Boolean logic? if directory a contents == directory b contents ...
1
vote
3
answers
262
views
diff: Find files that differ and are in the second directory
Say that I have these files for example:
old/common-change/index.html
new/common-change/index.html
new/only-new/index.html
old/only-old/index.html
The output of diff -qr is close to what I want:
$ ...
0
votes
1
answer
91
views
Relaxing cmp conditions on diff
Is there a independent diff tool that ignores differences as long as they're only related to row ordering and not content? For example,
a.txt:
aa
bb
and
b.txt:
bb
aa
should be identical, since they ...
1
vote
1
answer
42
views
How to compare corresponding multiple files with each other in the same directory
Hi so I have a folder like /mell/908 which contains files as follows:
cf-mell-pos-908-tcg-4619e.txt
cf-mell-pos-908-tcw-4619e.txt
cf-mell-pos-908-usc-4619e.txt
cf-mell-pos-908-wi_board-4619e.txt
...
6
votes
4
answers
5k
views
How to merge two folders so as to remove identical files from one, while keeping checksummed differentials?
I have a scenario where I have a recovery from a drive from possibly a different point in time that is not only potentially different in terms of files being present, but also there was some ...
1
vote
1
answer
2k
views
diff marking each line as old, new, or unchanged
I need to diff two unsorted text files with the output marking every line as either old, new, or unchanged. The marks should appear at the beginning or end of the line, and there should be no other ...
0
votes
1
answer
2k
views
How do I check the result of a command for an output vs no output in zsh if statement?
I would like to compare 2 files using diff and then if it returns nothing then echo "no diff" else display the difference. My current if statement only works if there is no difference but if there is ...
6
votes
3
answers
2k
views
Find files that have the same name as the directory
I have the next problem:
Directory Example1 has three files: Example1, Things and Pictures.
Directory Example2 has three files: Example2, Example3 and Pictures.
I need a list showing only the ...
-4
votes
1
answer
57
views
i want a linux script that will be able to compare both files and after comparing it should display something
file 1
products total
apple 6
yam 5
fish 6
meat 3
file2
products total
apple 6
yam 7
...
0
votes
1
answer
643
views
Can I use `diff` to display not the different but the matching parts?
man diff says:
diff - compare files line by line
So diff will compare the files. However, eventually, it will show the difference, if there is any. How can I compare the files and show the matching ...