date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,491,882,661,000 |
I have two env files, let's say x.env and y.env, the order of the variables is different, but the content could be the same but likely different.
Is there some tool I could use to diff the variables?
env -i (
# clear all envs
source x.env;
env | sort > x.sh
)
env -i (
# clear all envs
... |
If you're running bash or another shell that allows inline command redirection,
comm -3 <(sort x.env) <(sort y.env)
Or, to source the variables as shown in your question, you can try this but beware of differences in LC_* locale variables that may affect the sorting order - and in turn cause comm to complain that the... | diffing two .env files |
1,491,882,661,000 |
Why
I have two folders that should contain the exact same files, however, when I look at the number of files, they are different. I would like to know which files/folders are present in one, not the other. My thinking is I will make a list of all the files and then use comm to find differences between the two folders.... |
You don't need any of that, just use diff -qr dir1 dir2. For example:
$ tree
.
├── dir1
│ ├── file1
│ ├── file3
│ ├── file4
│ ├── file6
│ ├── file7
│ ├── file8
│ └── subdir1
│ ├── dsaf
│ ├── sufile1
│ └── sufile3
└── dir2
├── file1
├── file2
├── file3
├── file4
├── f... | Recursively list path of files only |
1,491,882,661,000 |
I use
diff -y <file1> <file2>
or
sdiff <file1> <file2>
but I can't find how to change markers from the defaults which are:
<
>
|
In particular, I would like to add a visible equality marker (as default one is a whitespace) replacing it with (for example):
=
to achieve something like:
ab c | ab d
efg = efg
Trie... |
The markers are handled in the last three functions of https://git.savannah.gnu.org/cgit/diffutils.git/tree/src/side.c in print_sdiff_hunk. There’s no option to override them.
You could post-process the output, relying on the fact that for a given width, the markers will always be in the same position in the output.
| How to change diff side by side markers to other ones? |
1,491,882,661,000 |
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
copper_qnt
tcg_mell_upload_lx.txt
tcw_mell_upload_lx.txt
usc_mell_upload_lx.txt
wi_board_mell_upload_lx.txt
Is there a way ... |
I propose this option, assuming the string that matches in every pair of files is always in the same position:
# loop over the files that start with 'cf-'
for f in cf-*.txt; do
# extract the unique "code", e.g 'tcg'
code=$(echo "$f" | cut -d'-' -f5)
# match the looped file with the one that starts with the "cod... | How to compare corresponding multiple files with each other in the same directory |
1,491,882,661,000 |
I have two files, both are outputs from a code that I have put through cut to only look at the first 26 characters of each line. Both files are lists of parameters that the code measured, such as "total cross section," or "neutron lifetime," as well as the options that code used like "MPI_TASKS," or "COMPILE_DATE" so ... |
By default, diff assumes some context around each part of the difference, called a chunk. If you reduce the context (using the optional value for the -C option), you reduce the chunk-size and make it less likely to report large (overlapping) chunks as a big difference.
| Diff acting very strangely, reports long blocks as deleted when short bits throughout the block have been changed, deleted or added |
1,491,882,661,000 |
I have 2 different branches A,B that have a (slightly different) version of a file X.
I am interested in getting the commits that added some specific patterns in branch B.
What I do roughly: diff files| grep "^\+" | grep "$PATTERN" | for loop grep -n.. do git blame -L done
This works but I was wondering if I am re-inv... |
I think you can combine git blame and git merge-base to get the information you’re after:
git blame -n $(git merge-base A B).. -- file | grep -v "^^" | grep "$PATTERN"
This finds the common ancestor between A and B, then runs git blame on file, ignoring anything older than the common ancestor (the .. notation tells g... | Getting differences of file between specific revisions/branches |
1,491,882,661,000 |
I'm trying to compare a new file (e.g., new.txt) to an old file (e.g., old.txt) to see what was added in the new file. I'm trying to add the newly added information to a new file called newCourses.txt and the modified information to modifiedCourses.txt. If this is not possible with a diff, what are the alternatives wi... |
You could use awk:
awk 'NR==FNR{ z[$5]=$0; next}{ if ($5 in z){ if ($0!=z[$5]){
print >"modifiedCourses.txt"}} else { print >"newCourses.txt"}}' old.txt new.txt
This reads old.txt and saves the lines into an array (the indices are the names of the courses) and then reads new.txt and for each course it checks if it's ... | Saving diffs to two files for modified and new additions |
1,491,882,661,000 |
I was using MELD but it can't seem to sort by modification time, so I've been looking for a way to achieve something similar in terminal. I found a line of code
find /path/to/dir1 /path/to/dir2 -printf "%TY-%Tm-%Td %TH:%TM %p\n" | sort -r
which seems to output the differences (including new files) between directorie... |
ls
ls -lrt /path/to/dir1 /path/to/dir2 | head -N
note that you have directories as well.
find
you almost made it
find /path/to/dir1 /path/to/dir2 -type f -printf "%TY-%Tm-%Td %TH:%TM %p\n" | sort | tail -N
this will give you the N newest modified file. (oldest first)
use ... | sort -r | head -N to have newe... | diff files within dirs listing by date modified |
1,491,882,661,000 |
I'm running this code on shell
mv -f ~/sites/text1.txt ~/sites/text2.txt;find ~/sites/ -type f -exec sha1sum {} >> ~/sites/text.txt \;diff ~/sites/text1.txt ~/sites/text2.txt;
However every time I'm having this error:
find: missing argument to `-exec'
Please anyone figure out how to get this code work?
|
mv -f ~/sites.data/text1.txt ~/sites.data/text2.txt &&\
find ~/sites/ -type f -print0|xarg0 -0r sha1sum |sort> ~/sites.data/text1.txt &&\
diff ~/sites.data/text1.txt ~/sites.data/text2.txt
changes I made: each command is now conditionally executed based on the success of the previous command, don't try to do io redi... | Running 'diff 'command after the 'find' command |
1,491,882,661,000 |
I'm using diff and patch to patch some files. In my situation, I am not permitted to distribute any of the original file.
Right now, the diffs look something like this:
1c1
< Hello, this is the original.
---
> Hey, this is the new version.
I don't want to (and for reasons can't) include the original lines. Is it poss... |
To capture what I understand from the Q's comments, I'm going to answer that "no, it is not possible to do what you want with diff and patch", since they must include context, which includes content that you can't distribute.
Given that you can't rely on ed to be present, if you can rely on sed to be there, then you ... | diff without including removed content |
1,371,650,681,000 |
Suppose i have 2 config files such as:
file 1:
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
virtual_gid_maps = static:5000
File 2:
virtual_gid_maps = static:5000
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
if you see carefully, you'll see ... |
If the positions are not important, you can sort the files and then, perform a diff. You will have to save the sorted files in temporary area.
sort file1 > /tmp/file1
sort file2 > /tmp/file2
diff /tmp/file1 /tmp/file2
You may also want to try vimdiff instead of diff.
| how to compare total file |
1,371,650,681,000 |
Why I can't do something like:
tail -n 5 small.txt | diff small.txt
I want to pass the execution result of the first command like second argument of the second, not stand alone input. How can I do it?
|
Try tail -n 5 small.txt | diff small.txt -.
From man diff:
If a FILE is '-', read standard input.
The - method shows you how to do correctly what you wanted to do. But the method below teaches you something that will make your (shell) life easier:
diff small.txt <(tail -n 5 small.txt)
| Trouble with piping |
1,371,650,681,000 |
I wrote a line like this diff fileA.txt fileB.txt | grep -v "^[11,12d9]" .
Without the grep part, the output would look like this:
1d0
< loop
11,12d9
< polo
< pool
But with grep, the output would look like this:
< loop
< polo
< pool
I think that grep -v is kind of like reverse search. But I don't und... |
grep -v "^[11,12d9]"
yes, as you found out -v is used for invert match and will return lines that do not match the given pattern ^[11,12d9].
and what ^[11,12d9] is doing is that saying match characters in [...] and if they were appeared at the begging of a line (^ is the beginning of the line anchor) then ignore those... | What does 'grep -v "^[...]"' mean? |
1,371,650,681,000 |
In diffutils' manual
diff3 mine older yours
You can remember the order of the arguments by noting that they are in
alphabetical order.
You can think of this as subtracting older from yours and adding the
result to mine, or as merging into mine the changes that would turn
older into yours. This merging is well-define... |
What does "mine and older match in the neighborhood of each such change" mean?
“mine and older match in the neighborhood of each such change” means that when considering each change between “older” and “yours”, the context of the change can be found in “mine” too. Put another way, it means that “mine” and “older” ar... | How shall I understand the conditions for merging by diff3 to be well-defined? |
1,371,650,681,000 |
Good day everyone,
I know there are a lot of similar questions already answered, but I can't find a satisfying answer and it drives me nuts.
I have two files which both contain hostnames : one that holds all the ones opened to the Internet, the other logs all the scan results of ALL our hosts, opened to Internet or no... |
Not being able to presort the files isn’t a problem:
comm -13 <(sort fileA) <(sort fileB)
This gives
1199.com
1299.com
www2.1329.com
with your examples, assuming each host is on a separate line. -13 tells comm to drop column 1 (lines unique to the first file) and 3 (lines common to both files), leaving only lines un... | Print only what is exclusive to a file compared to another in Bash |
1,371,650,681,000 |
A previous answer to a post mentions to run sha1 hashes on an images of a dd drive clone image.
Another answer to that post suggests mounting the dd image an then compare if the sha1 hashes of "important files" matches.
I want to use the second approach, but instead of manually selecting files I would like to use a bu... |
As I understand your question you want to find out whether N random files differ between two file system paths. Comparing the files should be faster than calculating checksums of both files. Here is how you can do it:
#!/bin/sh
list1=/tmp/list1
list2=/tmp/list2
shuflist=/tmp/shuflist
n=100000 # How many files to compa... | check two partitions by selecting random files and running sha1 hashes on two files of each partition |
1,371,650,681,000 |
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 have the same contents (white spaces are assumed to be
the same for both files).
The easiest solution would be to simpl... |
You can sort both files and compare the result:
cmp <(sort a.txt) <(sort b.txt)
(or diff ...).
| Relaxing cmp conditions on diff |
1,371,650,681,000 |
I have the output from my diff command between two directories store in a file called differenceOutput.txt.
At present there are only two kinds of lines in differenceOutput.txt So all lines have either format A or B, where A and B look like this:
A)
Only in /tmp/__tmp_comp206_alex/test_files/: file_1.txt
B)
Files /tm... |
$ awk '
sub(/^Only in /,"") { sub(/: /,""); $0=$0 " is missing" }
sub(/^Files /,"") { sub(/ and .*/,""); $0=$0 " differs" }
1' differenceOutput.txt
/tmp/__tmp_comp206_alex/test_files/file_1.txt is missing
/tmp/__tmp_comp206_alex/test_files/file_3.conf differs
That assumes your directory names don't contain ... | Using sed to cut and add to specific lines of diff output |
1,371,650,681,000 |
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 then it gives me a "not found" error.
This is what the test.sh looks like:
#!/bin/zsh
if [$(diff file1 file2) = '']
the... |
diff provides an exit status of zero if no differences were found, so just use diff once and output message if required:
if diff file1 file2; then
echo 'no diff'
fi
diff utility may have the option -s/--report-identical-files (an extension to the POSIX specification). This would simplify the command to:
diff -s... | How do I check the result of a command for an output vs no output in zsh if statement? |
1,371,650,681,000 |
I have an alias which I use to strip out comments that are piped to it:
alias decomment='egrep -v "(^#.*|^$)"'
I'm currently having some difficulty with a squid proxy setup, so I want to compare come config changes. I want to use my decomment alias, as the squid.config file has a large number of commented-out lines.... |
You can use process substitution:
diff <(cat squid.conf.old | decomment) <(cat squid.conf.new | decomment)
| How do I diff the output of these two commands? [duplicate] |
1,371,650,681,000 |
Problem..{ I've users with home dirs in /home, so I can get a list of users matching my criteria with following command.
STEP 1: Fetching A List Of Users
du -h --max-depth=1 /home 2>/dev/null | egrep -v '(!G|.cp)' | awk -F"/" '{print $NF}'
Note: The extended grep pattern is my requirement because home dirs contain... |
Ok I researched a little bit and the solution I was looking for is this
comm -23 <(sort File1) <(sort File2)
| Getting Mismatched Entries In 2 Files [closed] |
1,371,650,681,000 |
Now here is the commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb, I want to get this commit id code which were modified only.
I use git show 41f9f4e392ab50db264e0328de7d69f1f10646eb to see modified files, how can I download these both after modified and before modified version via Linux git command? In a word, I jus... |
Thanks all, I have found the correct way, here it is.
#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while read line
do
#ech... | How to get the modified files(before and after) from git version server? |
1,371,650,681,000 |
I have two directories named comp1 and comp2 and both have files named file1 and file2.
I need a bash script which read file1 from both the directories and take diff of each file and redirect to some other file. For example.
diff comp1/file1 comp2/file1 > file1.diff
|
#!/bin/sh
for f in comp1/* ; do
diff "comp1/$f" "comp2/$f" > "$f.diff"
done
This script assumes you have files of the same name in both directories.
| Read files in Directory and take diff |
1,371,650,681,000 |
I am doing diff -rq to check the difference between 2 folders (A and B). I don't want to know if folder A has any new files because that's expected. How do I ensure that this information doesn't come up?
|
Expanding on my comment now that I'm at an actual keyboard:
The only way to do what you want is to diff files individually. We can combine find and xargs to do that, something like this:
(cd B && find . -type f -print0) | xargs -0 -IPATH diff -q A/PATH B/PATH
This produces a list of all files in B relative to the top... | How to prevent `diff -rq` from showing newly created files, when comparing the different versions of a folder? |
1,371,650,681,000 |
Using comm I get results that look weird from this:
comm -3 <(. "$first_env_file"; env) <(. "$second_env_file"; env)
I get something like:
AUTH_LP_ACCOUNT_ID=xxx1
AUTH_LP_ACCOUNT_ID=xxx2
AWS_IMAGE_DOMAIN_NAME=abc
AWS_IMAGE_DOMAIN_NAME=zyx
NODE_ENV=local
NODE_ENV=staging
NODE_PORT=3000... |
My only guess at 3 is to loop over each line (skipping first) and if the next result has a different xxx= vs abc= then print a -------- but I am not in love with that.
Your guess is just fine. Do it in awk.
comm ... | sed 's/^\t//' | awk -F= 'NR == 1 {cur = $1; print "---- begin ----"} cur != $1 {print "---------"}... | Group results using comm |
1,371,650,681,000 |
[ EDIT:
Answered my own question.
Used unison and some hacky post-processing
(
copy-pasted the log output of unison,
tweaked it in my text-editor with multi-selection editing,
then did some shell script processing on that (fishshell)
)
((I've got so much more disaster recovery stuff to slog through, so I guess I'm don... |
unison
This worked for me in the end.
Here's the output data from unison,
plus a bit of manual checking I did on it using my fishshell at the end.
data from unison
$unison dir_A dir_B
reported a bunch of errors "unknown file type" for the weird stuff from the bootable system
but then a summary:
0 items will be sync... | Best way to compare/diff two big directories that are backups (by `rsync -aAX`) of a boot partition from another computer? |
1,371,650,681,000 |
I need to diff (and merge) two directories (practically same content, with a few extra inserted lines in one set of files). Alas, all diff programs I tried (kompare, diffmerge, kdiff3, diffuse, xxdiff, ) don't do a good job of showing the differences (screenshot from intellij idea); or are limited to diffing files (in... |
I use meld for diffing both files and folders. It is a free and open-source GUI app and its UI is intuitive and very user-friendly. It is fast but can become slow when comparing directories with non-text files.
This is how the diff between your two folders appears in Meld:
And below is the comparison of one of the mo... | Diffing two directories well |
1,371,650,681,000 |
I have the following files:
a.txt
1
2
11
22
33
444
b.txt
1
2
3
11
22
33
555
I want to retrieve the lines from a.txt that do not exists on b.txt.
I tried with that:
diff a.txt b.txt -d
2a3
> 3
6c7
< 444
---
> 555
But I want the output to be
444
Only. Is there a way to place some sort of filters upon diff?
|
It would be better to use grep
grep -f b.txt -v a.txt
Key -f will define b.txt as list of patterns to search in a.txt. And key -v will reverse the search and printout line from a.txt where the pattern was not found.
| How I can get the missing lines from a.txt files using diff? |
1,371,650,681,000 |
How can git diff color be changed to one's disposal, or such as for diff ...?
in ~/.gitconfig:
[color "diff"]
added = yellow
changed = red bold
not work.
Please sincere help appreciated
|
The git-config(1) manual details the available slots; your added and changed might work instead as new and old.
color.diff.<slot>
Use customized color for diff colorization. <slot> specifies which
part of the patch to use the specified color, and is one of context
(context text - plain is a hi... | Have git diff color customization |
1,371,650,681,000 |
This might be answered already but it is hard to search for -- basically,
When patch find a block/hunk unable to apply, it will reject the changed hunk into reject file.
How not to put the conflicts in reject file but include in the final output, just as when git find the conflicts and include both versions in the fin... |
GNU patch has a --merge option:
--merge or --merge=merge or --merge=diff3
Merge a patch file into the original files similar to diff3(1)
or merge(1). If a conflict is found, patch outputs a warning
and brackets the conflict with <<<<<<< and >>>>>>> lines. A
typical conflict will look like this:
<<<<<<... | patch without reject |
1,371,650,681,000 |
I have 2 ~55 Gb folders (with many subfolders) that contain more than 1500 files per ~30 Mb.
I need to compare them and get information if some files are missing / new files persist or their hash is not identical to original content.
How I can do it?
|
You can try something like:
cd path1
find . -type f -exec sha1sum {} \; >/var/tmp/sum.path1
cd path2
sha1sum -c /var/tmp/sum.path1|grep -v "OK$"
(the grep remove lines with OK at the end to display only failed missing/different hash)
And you can change the hash algorithm to try to minimize the collision factor
| How to diff folders and get verbose information? |
1,371,650,681,000 |
I want to know on which ports of firewalls from a particular customer the MAC Address Filtering is not active. So I have created 2 files:
all.txt contains a list of all firewalls of a customer and looks like this:
abc123
ahg578
dfh879
ert258
fgh123
huz546
jki486
lop784
mnh323
xsd451
wqa512
zas423
active.txt contai... |
grep -v will work, just swap source with target. - will use pipe for -f
instead -x whole line -w whole word is recommended to ignore whitespaces from all.txt
cut -d\ -f1 active.txt | grep -vxFf - all.txt
Note the two whitespaces for cut: one escaped whitespace as delimiter
edit: if delimiter is a colon one must cut ... | get only the unmatched list as an output |
1,371,650,681,000 |
I would like to diff two directories recursively, ignoring one particular string replacement.
For example, in one directory, some files contain the string "abcd" whereas in the other directory "abcd" has been renamed "wxyz" in those same files. I would like to see all differences between the two directories except for... |
One way to go about it is to preprocess one of the set of files (your question states that all folder1's files might have abcd and folder2's files might have wxyz.
For example find can do the file searching inside one the trees, say folder1, and feed that to a script.
Inside the script you run the substitution on the ... | recursively diff two directories ignoring a single word |
1,371,650,681,000 |
I've never used maintained files created with patch and diff. But what is the work flow when the patch drifts? As in this case. I can see the the failures when I do -m in the same format git would provide for resolution. But how can I, after I fix the problems, regenerate the patch with all the same information (note... |
You can use diff --unified file.orig file after a patch --merge to create a new patch file based on the changed file without git. It won't have the same information, though.
| Rebasing a patch without using git? |
1,371,650,681,000 |
I've pulled the source package of luajit with apt source luajit from Debian sid. As the package was unpacked by the same command, I saw the next message:
dpkg-source: info: applying 0002-Enable-debugging-symbols-in-the-build.patch
Although I did not ask for any patches to be applied automatically, I'd like to review ... |
It turned out to be a trivial confusion with quilt diff's -P and the [file ...] at the end of the quilt diff command. Apparently the ./ prefix before the filename of the patch breaks quilt's resolution within ./series when using -P, or rather that -P doesn't expect ./ at all. Therefore the correct syntax for:
quilt di... | How to review changes made by a .patch with quilt in a Debian source package? |
1,371,650,681,000 |
I have a short file (around 60 lines) which acts like a basic database it has three whitespace separated columns. The first one is name of the product, the second one is the price and the third one is the qunatity.
product1 5 25
product2 8 30
product3 15 80
product4 2 200
Then I create a new file which contains some ... |
Assuming your source file is data and your updates file is updates this short code will satisfy your requirement
awk '{ h[$1] = $0 } END { for (i in h) { print h[i] } }' data updates
awk code is split into stanzas:
{ h[$1] = $0 } # save each line, keyed by first element, overwriting as necessa... | How do I patch in to a file only the insertions and modifications leaving the unmodified lines there? |
1,371,650,681,000 |
I have two files:
File 1:
No ID CV CA1 CA2
1 transcr_10283 0.999023367236861 -0.344113101336184 -0.032235130455987
2 transcr_10371 -0.572755303094372 -0.579145581184253 0.879510598089221
3 transcr_10391 0.999589933675858 -0.379226454955611 -0.302057879326854
4 transcr_10428 0.128862262957329... |
With awk:
$ awk -v FS="\t" -v OFS="\t" 'NR==FNR {trans[$2"|"$3]++; next;} FNR==1 {print} FNR>1 {if(!trans[$2"|"$3]) print}' file2 file1
First file2 is read in and the value by column 2 and 3 are used to store thme as a key in a list.
If file1 is read in, the header line is printed. For each next line, we check if a... | How can I compare two files by using just two columns and print the difference (without sorting)? |
1,371,650,681,000 |
I'm having an extremely hard time to read this can someone explain what it means, and what the difference between the two is ?
$> diff -U 3 user_output_test1 test1.output | cat -e
--- user_output_test1 2018-10-31 22:21:45.000000000 -0700$
+++ test1.output 2018-10-31 22:21:45.000000000 -0700$
@@ -9,8 +9,8 @@$... |
user_output_test1 has two lines:
'2-A' '0123456789ABCDEF'=0
'+2-A' '0123456789ABCDEF'=0
that differ from test1.output, who has these two lines, instead:
'2-A' '0123456789ABCDEF'=2
'+2-A' '0123456789ABCDEF'=2
The substantive difference being the =0 turning into =2's.
The leading - symbol indicates lines that would be... | Can someone explain to me what this **diff** means..? [duplicate] |
1,371,650,681,000 |
Consider the need to use 'diff' to compare two files with many commented lines, such as system configuration files. (For example, the files could be /etc/cups/cups-files.conf.pacnew and /etc/cups/cups-files.conf.)
I would like to ignore differences of any lines that are commented out such as these:
< #DocumentRoot /u... |
You can filter the commented lines before comparing the files:
diff -u -w <(grep -v '^[[:space:]]*#' /etc/cups/cups-files.conf.pacnew) <(grep -v '^[[:space:]]*#' /etc/cups/cups-files.conf)
That way diff will only see uncommented lines, and will only compare those.
| diff of config files showing only uncommented lines |
1,371,650,681,000 |
I want to know the individual difference between n files, so similar to this:
parallel --tag 'diff {1} {2} | wc -l' ::: * ::: *
A big problem here is binary files, and a single megalong line will count the same as a short line.
How do I generate a fuzzy diff over n files?
|
Use ssdeep to generate a hash file:
ssdeep `find . -type f` > hash
This will give the pairs with 90% <= similarity < 100%:
ssdeep -m hash `find . -type f` | grep -E '9[0-9].$'
This only works if long stretches (blocks of around 1% of file size) are the same.
| Fuzzy diff n by n files |
1,371,650,681,000 |
Is there a way or a tool to get percentage of difference between two strings (no new line characters, no files)?
For example, if there are 2 strings and each of them is 10 characters long and differ only in 1 character, then the difference should be 10%.
The strings may have different lengths and can hardly become lon... |
The Levenshtein distance is a useful metric to give an idea of the amount of difference between two strings. It measures the number of insertions, deletions and substitutions needed to get from one string to the other.
For instance, if you compare abcdef and bcdef, all characters are different if you compare them one ... | diff percentage between two strings |
1,371,650,681,000 |
I have a script that logs in to around 30 pairs of routers. The script runs a command and saves the output to a file, then moves on to the next router and so on.
I now want to run a 'diff' on each pair of router's files and then 'diff' the next pair, etc. e.g. diff rtr_1a rtr_1b then diff rtr_2a rtr_2b and so on....
H... |
Assuming all files are called rtr_ia and rtr_ib for i between 1 and 30:
#!/bin/bash
for (( i = 1; i <= 30; ++i )); do
diff "rtr_${i}a" "rtr_${i}b"
done
To save the diffs into files:
#!/bin/bash
for (( i = 1; i <= 30; ++i )); do
diff "rtr_${i}a" "rtr_${i}b" >"rtr_${i}.diff"
done
After comments:
#!/bin/bash... | for loop to diff pairs of files |
1,371,650,681,000 |
I'm currently doing some consolidation of i18n files. In some cases I have duplicate keys across multiple files, and I want to figure out if I can remove one of the duplicates.
Here's an example:
config/locales/en-primary.yml: language_key: 'lorem ipsum'
config/locales/en-secondary.yml: language_key: 'lorem ipsum'
... |
If it's just the two files:
diff <(grep 'language_key' config/locales/en-primary.yml) <(grep 'language_key' config/locales/en-secondary.yml)
| Is there a way to diff a line from different files? |
1,371,650,681,000 |
I have a list that i've copy and i want to paste it to the shell to give me just the repeated lines.
1
1
3
2
As i read about bash commands i've maded this:
cat > /tmp/sortme ; diff <(sort /tmp/sortme) <(sort -u /tmp/sortme)
When i write the above command i paste my list and press CTRL+Z to stop cat and it shows me... |
#!/bin/bash
while :
do
echo Paste some input, then press Control-D:
cat > /tmp/sortme ; diff <(sort /tmp/sortme) <(sort -u /tmp/sortme)
done
| How to turn Diff command into bash script with prompt |
1,371,650,681,000 |
I have a lot of logs I would like to compare. The problem is, that the first few characters in a line are a timestamp. How can I compare logs, ignoring timestamps.
For example, these two should be the same:
httpd:debug:64.715:rutWan_getIpOrPppObjectByIfname:2124:looking for eth1
httpd:debug:64.717:rutWan_getIpOrPppObj... |
You can use cut to get rid of the timestamp "column"
cat logfile | cut -d":" -f1,2,4- > logfile_notimestamp
if you do this for both files, you can easily compare them using diff.
| Compare logs without timestamp |
1,371,650,681,000 |
I have configured git diff to be a command that calls substitute diff for viewing file differences i.e /usr/bin/vim -dR "$2" "$3" and that doesn't work when I want to create a patch using git diff > patchfile.
Is there a way to invoke directly git's own built in diff without disabling the subsitute diff I use for visu... |
git diff --no-ext-diff
In general look for a --no-thing option for turning whatever --thing off. git(1) has a lot of those. Good for conveniently turning off defaults. Sometimes they’re documented together as --[no-]thing and sometimes separately in the man pages.
| How can I call git's built-in diff command directly after configuring a different visual "git diff" substitute? |
1,371,650,681,000 |
Referring to this https://stackoverflow.com/a/31356602, I wrote this code:
#!/bin/bash
# Define the two strings to compare
string1="First string with some random text."
string2="Second string with some random text and some changes."
# Create a temporary directory
temp_dir=$(mktemp -d)
# Create temporary files for t... |
This won't be possible with pipe-based redirection as in your bash's <().
But: with zsh-isms, it should work. There is the temporary file expansion =():
#!/usr/bin/zsh
# use zsh instead of bash
# Define the two strings to compare
string1="First string with some random text."
string2="Second string with some random te... | Performing character-level comparison of "strings" without explicitly creating temporary files for git diff |
1,371,650,681,000 |
I'm using git diff to return the file names of files recently changed and i'm trying to pipe the returned file names into a grep expression that searches each file and returns the files that have "*.yml" in the file name and "- name:" in the actual file. However it seems like my code only returns all the files in the ... |
git diff --name-only produces a list of files; you need to give that list to grep in a form it will understand, i.e. as command-line arguments. One way to do this is
git -C "${dir}" diff -z --name-only HEAD^ HEAD | xargs -0 grep -lw --include="*.yml" --exclude-dir="$excluded_paths" -e "- name:"
I added -z so that the... | Return list using git diff and grep |
1,371,650,681,000 |
I got the following results from diff:
@@ -4479,7 +4479,7 @@
|| AddPrintCheckParameters(TRUE)
|| AddRecipeDefaults(TRUE)
|| AddRepeatScanPass(TRUE)
- || AddVirgoFlag(TRUE)
+ || AddVirgoFlag(TRUE)
|| AddAttrPatchSize(TRUE)
|| AddDualSensParameters(TRUE)... |
By selecting both lines with the mouse to they are highlighted, I can clearly see that the first (deleted) line has trailing spaces that the second does not.
If you use diff -w this difference would be ignored by diff.
| Confusing Results from diff |
1,652,411,180,000 |
I am using this diff to show whether two files differ, but I need the regex to ignore the lines that are different that I don't care about. But the way it is set up it changes the names of the files when it reports a difference.
diff -q --suppress-common-lines -B <(grep -vE '\s(name|timestamp|root)=' goldcopy.xml) <(... |
What diff actually compares in your oneliner, are not the files but the output of grep. For each of those two file descriptors dynamically are created by shell (bash), /dev/fd/63 /dev/fd/62 are they usual names. <( command ) idiom is known as process substituion,
So there's no direct way for diff to know the original ... | How to keep file names when using diff with regex |
1,652,411,180,000 |
You constantly see kernel patches where it's a/subdir/file.c b/subdir/file.c. Say in reality you have linux-5.10.37_org and linux-5.10.37_mod, is there a way to get the a and b output without having to rename the directories?
Thanks.
|
You’d have to post-process the patch to do this, but you don’t need to: the base directory names are ignored in most cases. a and b aren’t real directories, they are the names produced for patches representing changes in a git repository.
If you really want to produce git-style patches for the kernel, the best way is ... | Can diff change the root path name in its output for patch files? |
1,652,411,180,000 |
I am trying to create a script to monitor a web page and send a telegram notification whenever there is a change in that page, I am using diff to accomplish this task.
The script seems to work well but some web pages insert a kind of random ID in the content of the page, this ID changes every time I download the page ... |
Assuming you are on GNU sed version of the sed editor.
Try to null the path d data in both fileold and filenew files before diffing. So you could do something along these lines:
sed -i '
/<path d=/c\
<path d=/>
' -- "$fileold" "$filenew";
Or if you must need to make sure that the characters in between the quotes ar... | How to use sed to remove letters, numbers, spaces, hyphens from the same linux string |
1,652,411,180,000 |
Currently, I am editing files on vim by setting patchmode=.orig and then, having two files:
file.txt.orig <- backup without changes
file.txt <- update file
However, I would like to generate a diff without having to rename the .orig file, so patch understands it is just file.txt which has been updated.
Ideally I woul... |
The workflow works for me. Perhaps you're testing by trying to apply the patch the file you've previously updated?
Preparation
echo this is original >file.txt.orig
echo this is new >file.txt
diff -u file.txt.orig file.txt >file.diff
cat file.diff
--- file.txt.orig 2021-05-03 19:17:13.038918015 +0100
+++ file.tx... | how to diff automatically between file.txt.orig and file.txt |
1,652,411,180,000 |
I have a folder with a lot of subfolders and files (let's call it 'orig'), and another folder where a lot of the same files were placed as backups in a different folder structure (let's call it 'backup'). I would like to list all of the files in 'backup' that do not yet exist in 'orig', so that I can put them in the c... |
I found a way how to solve my problem using python:
import filecmp
import os.path
def find_unique_files(path_orig, path_duplicates, ommit_in_orig=[]):
"""
Crawls all subfolders of path_duplicates and
returns list of files (incl. paths) that occur
in path_duplicates but no-where in path_orig,
excep... | How to list all files that occur SOMEWHERE in one folder but not another? |
1,652,411,180,000 |
I've got 2 very old Backups of a friends computer. They were simply copied into a folder each on an external Harddrive. Both are about 300GB in Size and the contents are very much alike but not identical and the folder-structure is different. I want to free that space and make one single Backup of those two. I think a... |
If the aim is to preserve file content (avoid losing data), I would concentrate on file equality, not the naming of directories of files.
Start with running this on each of the top-level folders, and save the output (it will run for a while!).
find FolderA -type f -print0 | xargs -0 cksum > FoldA.cksum
find FolderB -t... | Compare large directories recursively - but ignoring sub-directories - compare two backups - with gui |
1,652,411,180,000 |
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 parts?
|
Output format of diff can be controlled , so for you case , you must 3 options :
diff --old-group-format='' --new-group-format='' \
--unchanged-group-format='%=' a.txt b.txt
the man diff is not useful better read info diff
or use comm
| Can I use `diff` to display not the different but the matching parts? |
1,652,411,180,000 |
I would like to compare two large files that are not close to 1Gb in size.
Kompare crashes when the files load is large. I configured Kompare as in the photo below:
I would like to present the differences in a way that Kompare does (i.e. clear and showing with colors and lines), manageable for people who are not fami... |
Is there a way to dump the output of diff into a file, so it can be read later by another program?
Yep!
diff --speed-large-files a.file b.file > diffoutput
This creates a file called diffoutput, and writes the output of diff to it.
I would like to present the differences in a way that Kompare does (i.e. clear and ... | Comparing two files with an easy readable GUI program? |
1,652,411,180,000 |
I have got some kind of software in version 1.2.0 (lets call it 120), my colleagues made changes in this software (they created custom module for this software by changing source code of software) lets call it 120-fr version. Since then software vendor made changes in software and most recent version of software is 1.... |
Is there any reason not to use git? It is really good at merging changes like these automatically, and is exactly what it's made for. This isn't directly an answer to the question, but an alternative solution.
Using git instead of diff, it would look something like this:
# copy your original code to a new folder
cp ... | diffing two version of software,and do the interdiff |
1,652,411,180,000 |
I am trying to achieve something along the lines of
diff -ywB --suppress-common-lines `git branch --merged prod-server` `git branch --merged test-server`
so that I can know the difference of what has been merged into my test server branch but not in my production server branch
But when I execute the command above my... |
Use process substitution on bash:
diff -ywB --suppress-common-lines <(git branch --merged prod-server) <(git branch --merged test-server)
| how to pipe output from git commands into unix diff utility? |
1,652,411,180,000 |
I'm using diff -rq to compare directories on a Mac OS X 10.6 server. In folder1, we have 'filename'. In folder2, we have'filename.archive' because folder2 is created by a file sync app that also archives the files it syncs.
We've just pulled folder1 from a backup and I want to see what, in folder2, is more recent and... |
You cannot do this with "just" diff as the filenames do not match in both directories and diff doesn't have anything build in to do the mapping.
What you can do is change to the "new" directory and do:
for i in *; do diff "$i" /path/to/other/dir/"$i"; done
or, change to the restored backup dir and do:
for i in *.arc... | Diff: slightly different filenames, same file |
1,652,411,180,000 |
Is there any good software that finds groups of multiple files that are similar, or where one file includes a part of another?
I have a directory with lots of files mixed up. Among the files, are different versions of files, and the file names are messed up.
|
What about using diff to compare two files, counting the lines of differentiated text with 'wc -l' and then counting the actual lines in both of the compared files. If the diff lines are significantly smaller than the actual lines of the files then it's safe to say the files are more similar than not. That's a start, ... | Is there an application to find similar documents? |
1,652,411,180,000 |
Hello,
I have an englishStrings.json file and when I make new edits/ additions to it, I need to copy the new changes to all the other language string.json files.
Before making any changes to englishStrings, the englishStrings and otherLanguageStrings have the same keys and same number of lines but values differ.
I am... |
Rather than looking at the issue as a text patching problem, we may see it as a JSON structure mering task, overwriting the keys+values of one JSON data structure with those of another.
Assuming that the typographical (fancy) quotes in the French file are actually ordinary double quotes, you can use the JSON processor... | Force Patch character differences to a file |
1,652,411,180,000 |
When comparing the file contents of two directories using diff dirA dirB, what are the differences between with or without the --brief option? As far as I notice, by default diff reports only when files differ.
PS - We may add -r for recuring into subdirectories, but it does not affect the concern in this question. I ... |
The --brief option only writes a line that two files differ. Without the option, diff will print a how those two files are different:
diff filea fileb:
diff texlive_packages.txt texlive_packages2.txt
384c384
< texlive-encxvlna.noarch
---
> texlive-encxvlsd.noarch
647c647
< texlive-lastpage.noarch
---
> texlive-lastsd... | diff with or without --brief |
1,652,411,180,000 |
I have two files with same header and structure and the first column is a key.
File 1:
key val1 val2 val3 val4 val5
Item1 10 12 44 88 22
Item2 33 33 43 77 22
Item3 28 44 55 22 11
Item4 12 55 55 14 44
File2:
key val1 val2 val3 val4 val5
Item1 10 11 44 99 22
Item2 33 ... |
awk -v ref=file1 '
{
getline refline <ref
if (NR == 1) split(refline, head)
nf = split(refline, a)
for (i = 1; i <= nf; ++i)
if ($i != a[i])
diffcol[++n] = i
if (n > 0) {
$0 = a[1]
for (i = 1; i <= n; ++i)
... | How to compare two tsv extract in Unix and print differences with key and header? |
1,312,577,351,000 |
According to the Filesystem Hierarchy Standard, /opt is for "the installation of add-on application software packages". /usr/local is "for use by the system administrator when installing software locally". These use cases seem pretty similar. Software not included with distributions usually is configured by default... |
While both are designed to contain files not belonging to the operating system, /opt and /usr/local are not intended to contain the same set of files.
/usr/local is a place to install files built by the administrator, typically by using the make command (e.g., ./configure; make; make install). The idea is to avoid cla... | What is the difference between /opt and /usr/local? |
1,312,577,351,000 |
Assume there's an image storage directory, say, ./photos/john_doe, within which there are multiple subdirectories, where many certain files reside (say, *.jpg). How can I calculate a summary size of those files below the john_doe branch?
I tried du -hs ./photos/john_doe/*/*.jpg, but this shows individual files only. A... |
find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} + | grep total$
If more than one invocation of du is required because the file list is very long, multiple totals will be reported and need to be summed.
| Find the total size of certain files within a directory branch |
1,312,577,351,000 |
What does the "etc" folder in the root directory stand for? I think knowing this will help me remember where certain files are located.
Update: Might be useful for others, the folder is used for "Host specific configuration files" - reference.
|
Define - /etc? has some good history.
You can find references to "et cetera" in old Bell Labs UNIX manuals and so on – nowadays it's used only for system configuration, but it used to be where all the stuff that didn't fit into other directories went.
| What does etc stand for? |
1,312,577,351,000 |
I read that there are two folders for unit files (not in user mode).
/usr/lib/systemd/system/: units provided by installed packages
/etc/systemd/system/: units installed by the system administrator
Conflicting with this understanding is the answer to this question: How to write startup script for Systemd. Can someone... |
The best place to put system unit files: /etc/systemd/system
Just be sure to add a target under the [Install] section, read "How does it know?" for details. UPDATE: /usr/local/lib/systemd/system is another option, read "Gray Area" for details."
The best place to put user unit files: /etc/systemd/user or $HOME/.config... | Where do I put my systemd unit file? |
1,312,577,351,000 |
On most FHS systems, there is a /tmp folder as well as a /var/tmp folder. What is the functional difference between the two?
|
/tmp is meant as fast (possibly small) storage with a short lifetime. Many systems clean /tmp very fast - on some systems it is even mounted as RAM-disk. /var/tmp is normally located on a physical disk, is larger and can hold temporary files for a longer time. Some systems also clean /var/tmp, but less often.
Also not... | What is the difference between /tmp and /var/tmp? |
1,312,577,351,000 |
I have an executable for the perforce version control client (p4). I can't place it in /opt/local because I don't have root privileges. Is there a standard location where it needs to be placed under $HOME?
Does the File System Hierarchy have a convention that says that local executables/binaries need to be placed in $... |
In general, if a non-system installed and maintained binary needs to be accessible system-wide to multiple users, it should be placed by an administrator into /usr/local/bin. There is a complete hierarchy under /usr/local that is generally used for locally compiled and installed software packages.
If you are the only ... | Where should a local user executable be placed (under $HOME)? |
1,312,577,351,000 |
I need to compile some software on my Fedora machine. Where's the best place to put it so not to interfere with the packaged software?
|
Rule of thumb, at least on Debian-flavoured systems:
/usr/local for stuff which is "system-wide"—i.e. /usr/local tends to be in a distro's default $PATH, and follows a standard UNIX directory hierarchy with /usr/local/bin, /usr/local/lib, etc.
/opt for stuff you don't trust to make system-wide, with per-app prefixes—... | Where should I put software I compile myself? |
1,312,577,351,000 |
Or: where can I put files belonging to a group?
Suppose there are two users on a Unix system: joe and sarah. They are both members of the movies-enthusiast group. Where should I put their movie files?
/home/{joe,sarah}/movies are not appropriate because those directories belongs to joe / sarah, not to their group;
/h... |
Don't use
/usr is for sharable read-only data. Data here should only change for administrative reasons (e.g. the installation of new packages.)
/opt is generally for programs that are self-contained or need to be isolated from the rest of the system for some reason (low and medium interaction honeypot programs, for e... | What's the most appropriate directory where to place files shared between users? |
1,312,577,351,000 |
Before today, I've used the terminal to a limited extent of moving in and out of directories and changing the dates of files using the touch command. I had realised the full extent of the terminal after installing a fun script on Mac and having to chmod 755 the file to make it executable afterwards.
I'd like to know w... |
/usr/local/bin is for programs that a normal user may run.
The /usr/local hierarchy is for use by the system administrator when installing software locally.
It needs to be safe from being overwritten when the system software is updated.
It may be used for programs and data that
are shareable amongst a group of hosts,... | What is /usr/local/bin? |
1,312,577,351,000 |
I want to install a program in Linux and run it as a daemon. (Team Speak 3 in this case, but the question is general in nature). There is no package provided, only tarred binaries.
Where in the directory structure should I put such a program by convention?
On the web I found that /opt is for "optional addon apps", whi... |
The "more correct" depends on your distribution. You should check your distribution's guidelines on where to put software that isn't managed by the package manager (often /usr/local) OR on how to create your own package for it.
As you said, TeamSpeak just put everything in one folder (and may not be easy to reorganise... | Into which directory should I install programs in Linux? |
1,312,577,351,000 |
I have done some research about this on Google, but the results were cloudy. Why is the / sign used to denote the root directory. Are there any solid reasons behind it?
|
The forward slash / is the delimiting character which separates directories in paths in Unix-like operating systems. This character seems to have been chosen sometime in the 1970's, and according to anecdotal sources, the reasons might be related to that the predecessor to Unix, the Multics operating system, used the ... | Why is the root directory denoted by a / sign? |
1,312,577,351,000 |
I understand that in Windows as well as Linux and Unix, a program|application|software can be installed in any directory. Also if packages are installed using the distribution's packaging system, it'll place files in the correct location.
But at times, a software installation prompts for a path to place files. In case... |
The Linux Documentation Project has a description of the Linux filesystem hierarchy where they explain the different folders and their (partly historical) meaning.
As xenoterracide already pointed out /bin and /opt are the standard directories which can be compared to "Program Files" on Windows.
/bin contains severa... | What is the Linux equivalent to C:\Program Files? |
1,312,577,351,000 |
Installing something in windows takes a click of a button. But every time I try to install something in linux, which is not found in APT, I get so confused.
You download a zipped folder, then what? If you are lucky there is a README, refering to some documentation, which might help you, if you are lucky.
What is the... |
If it is a software which obeys the Filesystem Hierarchy Standard than you should place it in /usr/local and the appropriate subdirectories (like bin, lib, share, ...).
Other software should be placed in their own directory under /opt. Then either set your PATH variable to include the bin directory or whatever directo... | How do I know where to put things in linux? |
1,312,577,351,000 |
I am writing a script that I want to run without privileges. I want the errors that the script encounters to be logged to some log file. I do not not have privileges to write one to /var/log. And I do not want to have one in my home directory.
Is there a location where userspace scripts may log runtime information? Wh... |
You can't write to /var/log as a normal user, but the syslog daemon will do it for you if you ask. If you'd like to log messages to the standard system logs (e.g. /var/log/syslog), the 4.4BSD utility logger might be available on your system. It's installed by default on Debian, and is in the bsdutils package on Debi... | Where are userspace programs supposed to save their logs? |
1,312,577,351,000 |
Is there any difference between /run directory and var/run directory. It seems the latter is a link to the former. If the contents are one and the same what is the need for two directories?
|
From the Wikipedia page on the Filesystem Hierarchy Standard:
Modern Linux distributions include a /run directory as a temporary filesystem (tmpfs) which stores volatile runtime data, following the FHS version 3.0. According to the FHS version 2.3, this data should be stored in /var/run but this was a problem in some... | Difference between /run and /var/run |
1,312,577,351,000 |
My 64 bit Ubuntu 13.04 system has the following directories in /:
lib
lib32
lib64
libx32
libexec
In the /usr directory there is:
lib
lib32
libx32
libexec
This seemed like something that could be easily answered with a search, but I found nothing online, other than that these directories store shared libraries (excep... |
Ah yes this is a very confusing part if you've dealt with Unixes for any length of time. There is a standard that most Unixes "try" to follow called FHS - Filesystem Hierarchy Standard.
Given I primarily use Red Hat based distros I'm most familiar with their take on FHS for Fedora, CentOS, and RHEL Linux distros. But ... | Difference between lib, lib32, lib64, libx32, and libexec |
1,312,577,351,000 |
According to Wikipedia
http://en.wikipedia.org/wiki/Unix_directory_structure
http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
extra disks should not be mounted in /mnt/ according to the first link, but doesn't seams so according to the second link.
Both say thought that they shouldn't be in /media.
Question
... |
According to the FHS link that you gave
/mnt/ Temporarily mounted filesystems.
So I assume that you must mean permenantly mounted non-root non-system (meaning not /var/log or similar) filesystems.
I've always put them in /mnt/fsidentifier and then symlinked to then where needed.
So for instance, I had /mnt/website... | Where in "/" should extra permanent disks be mounted? |
1,312,577,351,000 |
From what I understand, the right place to put your own scripts is /usr/local/bin (for instance a script I use to back up some files). I notice that this folder is currently (by default) owned by root, and my normal user has no access to it. I am the only user on this computer. Shall I change this whole folder to my o... |
By default, the owner and group of /usr/local and all subdirectories (including bin) should be root.root and the permissions should be rwxr-xr-x. This means that users of the system can read and execute in (and from) this directory structure, but cannot create or edit files there. Only the root account (or an administ... | Permissions/ownership of /usr/local/bin |
1,312,577,351,000 |
I'm a long time Linux user for over 15 years but one thing I hate with a passion is the mandated directory structure. I don't like that /usr/bin is the dumping ground for binaries or libs in /usr/lib, /usr/lib32, /usr/libx32, /lib, /lib32 etc... Random stuff in /usr/share etc. It's dumb and confusing. But some like it... |
First, an up-front conflict-of-interest disclaimer: I am a long-time GoboLinux developer.
Second, an up-front claim of domain expertise: I am a long-time GoboLinux developer.
There are a few different structures in current use. GoboLinux has one, and tools like GNU Stow, Homebrew, etc, use something quite similar (pri... | What are the alternatives to the FHS? |
1,312,577,351,000 |
I have a config file which consists of list of URIs I want to download. For example,
http://xyz.abc.com/Dir1/Dir3/sds.exe
http://xyz.abc.com/Dir2/Dir4/jhjs.exe
http://xyz.abc.com/Dir1/itr.exe
I want to read the config file and and copy each URL but at the same time create the same directory structure as on the ... |
From man wget:
-x, --force-directories:
[...]
create a hierarchy of directories, even if one would not have been created otherwise. E.g. wget -x http://fly.srk.fer.hr/robots.txt will save the downloaded file to fly.srk.fer.hr/robots.txt.
| Download files and create same file structure as the source |
1,312,577,351,000 |
I'm curious to know: why are crontabs stored in /var rather than in the user's home directories? It makes it a total pain to isolate these files for upgrades but I suspect that there is a logical reason...
|
Few reasons I can think of:
In corporate environments, you can have thousands of users. If so, cron would have to scan through every single user's directory every single minute to check for the crontab file (whether it has been created, deleted, or modified).
By keeping them in a single location, it doesn't have to d... | Why aren't crontabs stored in user home directories? |
1,312,577,351,000 |
What are the "standards" -- should I put application (not just binary, but entire distribution) to /usr/local or /usr/local/share.
For example scala or weka -- it contains examples, binaries, libraries, and so on. So it would be
/usr/local/scala-2.9.1
or
/usr/local/share/scala-2.9.1
Since I am the only admin it i... |
I think /opt is more standard in this sort of context. The relevant section in the Filesystem Hierarchy Standard is quoted below.
Distributions may install software in /opt, but must not modify or
delete software installed by the local system administrator without
the assent of the local system administrator.
 R... | Should I put application into /usr/local or /usr/local/share? |
1,312,577,351,000 |
I have often started to think about this but never found a good answer. Why are these two Unix directories not /user and /temp instead?
All the other directories under root seem to be exactly what one would guess them to be, but these two seem odd, I would have always guessed them as user and temp.
Is there some histo... |
Yup there were reasons. They are pronounced user and temp. passwd is similar, as is resolv.conf. Unix is an expert friendly, user antagonistic operating system.
I was a student when 300 Baud modems were the norm. I was the envy of my fellow students, since I had a Silent 700 terminal from Control Data where I was work... | Why do /usr and /tmp directories for Linux miss vowels in their spellings? |
1,312,577,351,000 |
I was wondering what the difference between these two were:
~/somedirectory/file.txt
and
~/.somedirectory/file.txt
It's really difficult to ask this on Google since I didn't know how to explain the . when I didn't even know what to call it. But can someone describe the difference between including the dot and exclud... |
Under unix-like systems, all directories contain two entries, . and .., which stand for the directory itself and its parent respectively. These entries are not interesting most of the time, so ls hides them, and shell wildcards like * don't include them. More generally, ls and wildcards hide all files whose name begin... | What's so special about directories whose names begin with a dot? |
1,312,577,351,000 |
I am developing a daemon that needs to store lots of application data, and I noticed that on my system (Fedora 15), there is a /usr/local/etc directory.
I've decided to install my daemon to /usr/local/bin, and I need a place for my config files.
I didn't see this on Wikipedia. Is this non-standard or is this in fact t... |
/usr/local is usually for applications built from source. i.e. I install most of my packages using something like apt, but if I download a newer version of something or a piece of software not part of my distribution, I would build it from source and put everything into the `/usr/local' hierarchy.
This allows for sep... | What is the difference between /etc and /usr/local/etc |
1,312,577,351,000 |
Our sys admin installed a software application (Maven) on the server and told everyone to add the /usr/local/maven/bin/ folder to their path.
I think it could be more convenient to just link the few programs in that folder from the /bin folder (or other folder that everyone has in their path) like this:
ln -s /usr/loc... |
On linking
You generally do not link /usr/local/* with /bin, but this is more of a historical practice. In general, there are a few "technical" reason why you cannot do what you're suggesting.
Making links to executables in /bin can cause problems:
Probably the biggest caveat would be if you're system is having packa... | Adding to path vs. linking from /bin |
1,312,577,351,000 |
Let's say I have a top level directory called /dir and many sub directories. How do I search the subdirectories of /dir to find the one called x/x/dir/x/x/x/target?
This question is similar to, but not exactly what I am looking for: find command for certain subdirectories.
I am not looking for files, just directories... |
Try find /dir -type d -name "your_dir_name".
Replace /dir with your directory name, and replace "your_dir_name" with the name you're looking for.
-type d will tell find to search for directories only.
| How do I search all subdirectories to find one with a certain name? |
1,312,577,351,000 |
Originally in Unix, /usr was used for user (home) directories. So if I had a user named alex, my home directory would be /usr/alex. (Interestingly, Plan 9, the successor to Unix, still has user directories in /usr.)
Nowadays, of course, we store home directories in /home. (At least on GNU/Linux. I don't know about oth... |
This change was introduced by BSD after 1985 (BSD 4.2 was still documenting /usr) and in or before 1988 (BSD 4.3/SunOS 4.1 hier(7) manual page already documents /home). It was quickly followed by Solaris 2.0 (which kind of merged System V and BSD) and was later adopted by most other Unix vendors.
This is from the Sola... | At what point did the /home directory appear? |
1,312,577,351,000 |
In FHS-2.3, we have /media that holds mount points for removable media such as CD-ROMs and we have /mnt that holds temporarily mounted filesystems.
On the other hand, we have /run/media and /run/mount. For me, the CDs and USBs are mounted on /run/media.
I don't see any clear distinction between them(/media, /mnt, /run... |
FHS v2.3 was released ten years ago. Some things have changed since then (including the introduction of /run1). About three years ago, the Linux Foundation decided to update the standard and invited all interested parties to participate.
You can view the v. 3.0 drafts here and the section that describes /run here.
The... | what is the distinction between /media, /mnt and /run/mount? |
1,312,577,351,000 |
I have several closely related questions about what happens when I insert a CD. The files on the CD /media/Ubuntu\ 11.04\ i386/, but from what I've seen /dev/cdrom is also involved.
What is the difference between /dev,
/media and /mnt? Following is what I
have found from internet but I still
have little idea:
/dev... |
There are a lot of questions here and I'll do my best to answer them. I'm certain that those more knowledgeable than I will be able to help you further. (I'd appreciate if those people could help me out too.)
In *nix, everything is a file. For example, your CD-ROM is a file.
/dev - Here you'll find physical devices a... | Mounting a device — role of /dev, /media and /mnt, and the mount command [closed] |
1,312,577,351,000 |
I want to refactor the files and directories on my system. However I am not sure what is best practice.
After reading this question and its answers I assume the most important part is to be consistent. However, this is where I'm stuck. E.g. in root, there are directories such as /bin and /usr, which all use lower-case... |
There are a couple conflicting parts here. The comment about being able to do whatever you want is true, but it will also make much more work for you in the long run.
If you have any idea about re-arranging anything outside of your home directory, stop! That's way more complicated than you think and you should leave i... | File and directory naming conventions |
1,312,577,351,000 |
What is the difference between /lib and /usr/lib and /var/lib? Some of the files are symbolic links that "duplicate" content of other directories.
|
Someone else can probably explain this with much more detail and historical reference but the short answer:
/lib
is a place for the essential standard libraries. Think of libraries required for your system to run. If something in /bin or /sbin needs a library that library is likely in /lib.
/usr/lib
the /usr directo... | What is the difference between /lib and /usr/lib and /var/lib? |
1,312,577,351,000 |
When I run find with -execdir I don't get the results I was expecting.
For example:
mkdir -p a/b/c
find . -type d -execdir touch foo \;
$ tree a
a
├── b
│ ├── c
│ └── foo
└── foo
Directory c does not contain a foo file.
How do I get find to visit and do something locally in each directory?
|
For every matching file (i.e. every directory), find switches to the directory that contains it (i.e. its parent directory) and executes the specified command. Since the command doesn't use the name of the match, it's never going to act on all the directories. For this particular directory tree, you're doing
(cd . && ... | find with -execdir |
1,312,577,351,000 |
What is the purpose of having both? Aren't they both used for mounting drives?
|
I recommend visiting the Filesystem Hierarchy Standard.
/media is mount point for removable media. In other words, where system mounts removable media. This directory contains sub-directories used for mounting removable media such as CD-ROMs, floppy disks, etc.
/mnt is for temporary mounting. In other words, where us... | What's the difference between mnt vs media? [duplicate] |
1,312,577,351,000 |
Coming from the Windows world, I have found the majority of the folder directory names to be quite intuitive:
\Program Files contains files used by programs (surprise!)
\Program Files (x86) contains files used by 32-bit programs on 64-bit OSes
\Users (formerly Documents and Settings) contains users' files, i.e. docum... |
Linux distributions use the FHS: http://www.pathname.com/fhs/pub/fhs-2.3.html You can also try man hier.
I'll try to sum up answers your questions off the top of my head, but I strongly suggest that you read through the FHS:
/bin is for non-superuser system binaries
/sbin is for superuser (root) system binaries
/usr... | Standard and/or common directories on Unix/Linux OSes |
1,312,577,351,000 |
$ ls -l /dev/stdin /dev/fd/0
lrwx------ 1 tim tim 64 2011-08-07 09:53 /dev/fd/0 -> /dev/pts/2
lrwxrwxrwx 1 root root 15 2011-08-06 08:14 /dev/stdin -> /proc/self/fd/0
$ ls -l /dev/pts/2 /proc/self/fd/0
crw--w---- 1 tim tty 136, 2 2011-08-07 09:54 /dev/pts/2
lrwx------ 1 tim tim 64 2011-08-07 09:54 /proc/self/fd/0... |
/dev/fd and /proc/self/fd are exactly the same; /dev/fd is a symbolic link to /proc/self/fd. /proc/self/fd is part of a larger scheme that exposes the file descriptor of all processes (/proc/$pid/fd/$number). /dev/fd exists on other unices and is provided under Linux for compatibility. /proc/*/fd is specific to Linux.... | How does /dev/fd relate to /proc/self/fd/? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.