Reformatting and adding comments to Scrutinizer's code:
Code:
awk -F'[()]' ' # Set input field separators to the open and close
# parenthesis characters.
!/ProcessID: /{next} # Skip any line that does not contain "ProcessID: "
{p=$(NF-1)} # Set p to the last string on the line between "(" and
# ")". Presumably this sets p to the processID on
# the current input line from either input file.
NR==FNR{A[p]++; next} # If this line was read from the 1st input file,
# increment the count of the number of time we have
# seen this processID in the 1st input file, and
# skip to the next input line.
p in A{print p} # If the processID seen on this line in the 2nd input
# file was also seen in the 1st input file, print
# the processID.
' file1.log file2.log # End the awk script & name the 1st and 2nd input files.
My reading of your requirements was that you wanted to print processIDs that appear in file2.log that DO NOT also appear in file1.log. If that is what you want, I believe the line shown in red above should be changed to:
Code:
!(p in A){print p} # If the processID seen on this line in the 2nd input
# file was not seen in the 1st input file, print
# the processID.
And, I don't see any need to count the number of appearances of each processID in the 1st file, so the line:
Code:
NR==FNR{A[p]++; next}
could be simplified to just:
Code:
NR==FNR{A[p]; next}
to just note that the processID identified by p was found in the 1st input file (without counting the number of times it has been found).
I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ?
Source File
*************
# file: /local/test_1
# owner: own
#... (4 Replies)
Hi
I have file1 as
IJU_NSOMOW;
SOWWOD_TWUIQ;
and file2 as
how are you?;
fine there;
Now my problem is i need the output file as
IJU_NSOMOW; how are you?;
SOWWOD_TWUIQ; fine there; (2 Replies)
I have logs files which are generated each day depending on how many processes are running. Some days it could spin up 30 processes. Other days it could spin up 50. The log files all have the same pattern with the number being the different factor. e.g.
LOG_FILE_1.log
LOG_FILE_2.log etc etc
... (2 Replies)
Hi all,
I have 3 files with such data
first files
second file
third file
I have to find common entries of first column in two ways
1) between 2 files (2 Replies)
Hi all,
I have 2 big files with such kind of inputs
File I
File II
I want the output file shuld contain
Please let me knw scripting regarind this (1 Reply)
I have to compare 2 files which means 2 files with common entries in same column and separate those common entries in a diferent file as well right before those entries common so that I can separat common and Uncommon entries in rows in 2 different files. Is it possible
For eg.
one file
... (3 Replies)
Hello,
I need to find all *.xml files that matched by pattern on Linux. I need to have written the file name on the screen and then change the pattern in the file just was found.
For instance.
I can start the script with arguments for keyword and for value, i.e
script.sh keyword... (1 Reply)
I have 10 appservers and each appserver has 4 jvms . Each of these logs is archived and stored on a nfs directory . For example the files are
/logs/200907/ap1-jvm1.server.log.20090715.gz
/logs/200907/ap2-jvm2.server.log.20090714.gz
/logs/200908/ap1-jvm1.server.log.20090812.gz
I want to... (3 Replies)
Hi,
I need a shell program that will prompt the user to input a dept name to the script.
The script should then check a specific directory called ‘report' in the home directory of each member of that dept.
If the report directory does not exist, or there are no contents in the directory,... (2 Replies)
Hi,
I have a file having some thousand records with the following sort of lines:
Error: Failed to get order data
Order: PO-BBBTGZE
Error: No CLI
Error: Failed to get order data
Order: PO-SBDJUZA
Order: PO-XBBIDEN
Error: No CLI
Error: Failed to get order data
Order: PO-BBDJUTQ
Order:... (2 Replies)