Tag Info

New answers tagged

0

This is just a followup of @user17591 solution -- vim scripting: #!/usr/bin/vim -ns :%s%^+ %+++ :%s%^- %--- :%s%^ % :set nu :let html_use_css=1 :so $VIMRUNTIME/syntax/2html.vim :wq :qa! chmod it and Usage: htmlvim file (to produce file.html)


0

For those who have a command that is written on the assumption that piped output will never have color (e.g. some testing frameworks) you may find it useful to use the script utility to first save the ansi output. This can then be pushed to aha or the other utilities mentioned.


2

Traditionally, - means stdin (standard input). As you're redirecting, the output of the first command is the input of the second.


2

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.


0

Since version 3.3, GNU diff supports not dereferencing symlinks, but then compares the paths they point to. Install GNU diffutils >= 3.3 and use the '--no-dereference' option; there is no short option for that. Diagnostic will be silent if the paths are equal, or: Symbolic links /tmp/noderef/a/symlink and /tmp/noderef/b/symlink differ if the paths ...


0

With GNU awk you can do it in one line: awk '{a=$0;getline <File2;if($0 ~ a)print "OK"; else print a,$0}' File1


0

Try: paste file1 file2 | grep -vP '^(.*)\t.*\1.*' and possibly adapt the regex to your case.


0

Here is a one liner: If it finds what you are looking for, it displays "OK". If it doesn't, it displays the word it searched for. for i in $(cat File1); do grep -q $i File2 && echo OK || echo $i; done


0

Not very pretty perhaps but something like this could be a start: # 1. Read lines from file1 as string, and file2 as comma-separated array. while read -r a && IFS=, read -ra b <&3; do # 2. If both empty lines, continue. if [[ "$a" == "" && ${#b[@]} == 0 ]]; then continue fi # 3. Start assuming diff. diff=1 ...


0

Maybe this stack overflow answers put you in the right direction: Looping through the content of a file in Bash? String contains in bash Most probably you want to put each line of each file in a loop list or array, using the first suggestion. Then iterate over both of them simultaneous and compare the strings using the second suggestion.


1

With grep: diff -c file1 file2 | grep -v '^ ' none of the other lines start with two spaces: not the ones starting with !, and not the line indications.


1

with grep: diff -c file1 file2 | grep '^[-!*]'` with sed: diff -c file1 file2 | sed '/^[-!*]/!d'


2

With zsh: diff -u <(cd dir1 && printf '%s\n' **/*(D:r)) \ <(cd dir2 && printf '%s\n' **/*(D:r)) (D) to include dot-files (hidden files), :r to get the rest (remove extension). Using globbing guarantees a consistent sort order. (that assumes file names don't have newline characters).


2

You could use this command: comm -12 <(find dir1 -type f -exec bash -c 'basename "${0%.*}"' {} \; | sort) <(find dir2 -type f -exec bash -c 'basename "${0%.*}"' {} \; | sort) This uses find to list all the files in each directory, then basename and parameter substitution to strip off the directory names and file extensions. comm compares the two ...


1

This seems like a perfect opportunity to use comm. $ comm -1 -3 <(sort file1) <(sort file2) 12344 Dec 10 15:36 /opt/apache-tomcat-6.0.36/webapps/abc/.../test.txt 22677 Dec 3 15:36 /opt/apache-tomcat-6.0.36/webapps/new/abc.txt -1 and -3 removes all lines unique to file 1 and all lines common to both. Because of the sort, it will change the order of ...


0

use meld software utility . you can find it on software centre, its easy to use and also GUI based.


2

Use diff -u file1 file2 | sed -nr 's/^+([^+].*)/\1/p' Output: 22677 Dec 3 15:36 /opt/apache-tomcat-6.0.36/webapps/new/abc.txt 12344 Dec 10 15:36 /opt/apache-tomcat-6.0.36/webapps/abc/.../test.txt If you need the blank line between them, use diff -u file1 file2 | sed -nr 's/^+([^+].*)/\1\n/p' Output: 22677 Dec 3 15:36 ...



Top 50 recent answers are included