Tag Info

New answers tagged


I've found that sort seems to be the fastest uniq tool as shown here --> Fastest way to delete duplicates in large wordlist


How about the short, easy and straight way? awk '/#*\d/{print $2}' file | sort | uniq -d This allows to report host.domain duplicates even if they are commented out by a hash sign (#).


sed 's/\(.\)#.*/\1/' file | cut -f 2 -d\ | sort | uniq -d Remove comments that are preceded by anything sed 's/\(.\)#.*/\1/' Filter just the second column cut -f 2 -d\ Sort the lines for the following comparison sort And only print duplicates uniq -d Note that unless it is a possibility to have a line like banana.domain.net#comment You ...


If actual comment lines like the ones you've depicted at the beginning of your data exist and are to be ignored, I don't see how point 2 can be satisfied without some kind of assumption around how commented lines that are material can be told apart from commented lines that are to be ignored. I've made the assumption that commented lines that are material ...


This was a fun one. First, we need to eliminate trailing comments, as in: banana.domain.net # comment We can do that with the following (assuming just spaces, no tabs): sed 's/ *#.*//' If you have tabs in your hosts file, maybe run this first: tr '\t' ' ' Then we need to eliminate "comment out this line" comments, which I'm ...


This is what I came finally up with, thanks to the neat Perl command contributed by JJoao: # kill everything on termination trap "kill 0" SIGINT SIGTERM # Make sure the remote processes are killed on exit, see http://unix.stackexchange.com/questions/103699/kill-process-spawned-by-ssh-when-ssh-dies shopt -s huponexit ( while [ 1 -eq 1 ]; do ssh -t -t ...

Top 50 recent answers are included