#] #] ********************* #] "$d_SysMaint"'Linux/comm - compare files line by line notes.txt' # www.BillHowell.ca 09Jul2019 initial # view in text editor, using constant-width font (eg courier), tabWidth = 3 06Jan2020 to compare lists (see below section "06Jan2020 WCCI email list comparisons") : - convert lists to lower case - sort -u each list - comm -2 shows : - lines in file1 not in file2 without indent (tab) - lines in file2 that are in file2 as intented (tab) example : $ comm -2 "$d_temp""CEC givenList.txt" "$d_temp""WCCI list.txt" >"$d_temp""CEC newList.txt" #48************************************************48 #24************************24 # Table of Contents, generate with : # $ grep "^#]" "$d_SysMaint"'Linux/comm - compare files line by line notes.txt' | sed "s|^#\]| |" # #24************************24 # Setup, ToDos, #08********08 #] ??Feb2024 #08********08 #] ??Feb2024 #08********08 #] ??Feb2024 #08********08 #] ??Feb2024 #08********08 #] ??Feb2024 #08********08 #] 26Feb2024 search "Linux and how do I get common lines from files?" +-----+ https://stackoverflow.com/questions/373810/shell-command-to-find-lines-common-in-two-files Shell command to find lines common in two files Asked 15 years, 2 months ago Modified 1 year, 11 months ago Viewed 205k times The command you are seeking is comm. eg:- comm -12 1.sorted.txt 2.sorted.txt Here: -1 : suppress column 1 (lines unique to 1.sorted.txt) -2 : suppress column 2 (lines unique to 2.sorted.txt) edited Jun 27, 2017 at 9:58 Mohammed H answered Dec 17, 2008 at 6:40 Jonathan Leffler ******** #] 06Jan2020 WCCI email list comparisons https://stackoverflow.com/questions/2264428/how-to-convert-a-string-to-lower-case-in-bash#2264537 $ echo "$a" | tr '[:upper:]' '[:lower:]' ... edited Apr 12 '19 at 11:42 gaoithe 2,6022020 silver badges2020 bronze badges answered Feb 15 '10 at 7:43 ghostdog74 1. within IEEE ListServer http://listserv.ieee.org/ select WCCI export subscriptions to csv file "/media/bill/SWAPPER/Servers/IEEE ListServers/200106 WCCI email list.csv" 2. generate email-only list : $ cat "/media/bill/SWAPPER/Servers/IEEE ListServers/200106 WCCI email list.csv" | tr '[:upper:]' '[:lower:]' | sed 's/.\(.*\)\( "," \)\(.*\)/\1/' | sort -u >"$d_temp""WCCI list.txt" 3. manually chop off 3-line header of "$d_temp""WCCI list.txt" 4. process new lists (these lines will vary depending on the format of the lists provided) : Note : the -P option is specific to GNU grep! $ cat "/media/bill/SWAPPER/Servers/IEEE ListServers/200104 chris dyer cec2019-users.txt" | tr '[:upper:]' '[:lower:]' | sed 's/.*<\(.*\)>.*/\1/' | sort -u >"$d_temp""CEC givenList.txt" $ cat "/media/bill/SWAPPER/Servers/IEEE ListServers/200104 chris dyer fuzzieee2019-users.txt" | tr '[:upper:]' '[:lower:]' | sed 's/.*<\(.*\)>.*/\1/' | sort -u >"$d_temp""FUZZ givenList.txt" $ cat "/media/bill/SWAPPER/Servers/IEEE ListServers/200104 chris dyer ijcnn2019-users.txt" | tr '[:upper:]' '[:lower:]' | sed 's/.*<\(.*\)>.*/\1/' | sort -u >"$d_temp""IJCNN givenList.txt" 5. Compare to lists provided to generate lists of new emails : Note : lines in both file1 and file2 appear indented, hence the grep Note : grep option -P is specific to GNU grep $ comm -2 "$d_temp""CEC givenList.txt" "$d_temp""WCCI list.txt" | grep --invert-match -P '\t' >"$d_temp""CEC newList.txt" $ comm -2 "$d_temp""FUZZ givenList.txt" "$d_temp""WCCI list.txt" | grep --invert-match -P '\t' >"$d_temp""FUZZ newList.txt" $ comm -2 "$d_temp""IJCNN givenList.txt" "$d_temp""WCCI list.txt" | grep --invert-match -P '\t' >"$d_temp""IJCNN newList.txt" The numbers below refer to the email lists provided by Chris Dyer from Tomasz Cholewo : CEC emails : 1081 missing (i.e. 592 of 1663 were already present in WCCI ListServer) FUZZ emails : 1565 missing (i.e. 412 of 1977 were already present in WCCI ListServer) IJCNN emails : 1016 missing (i.e. 732 of 1748 were already present in WCCI ListServer) **************** #] 09Jul2019 see ""/media/bill/SWAPPER/bin/SSH/generate list of deactivates.sh"" inactives_list() { date_range="$1" p_excessiv="$d_sftp_access$2"" users - excessive accesses.txt" f_inactive="$2"" users - inactive.txt" find "$d_sftp_access""attendees/" | tr \\n \\0 | xargs -0 -IFILE tail -n 1 "FILE" >"$d_temp$f_inactive" grep --invert-match "$date_range" "$d_temp$f_inactive" | sed 's/\(.*\)Accepted password for \(.*\) from\(.*\)/\2/' | sort -u >"$d_sftp_access$f_inactive" cat "$p_excessiv" "$d_sftp_access""$f_inactive" | sort -u >"$p_inactEx" comm -23 "$p_inactEx" "$p_testers" >"$p_deactiv" } # enddoc