Sponsored Content
Top Forums Shell Programming and Scripting Comparing Data file with Crtl file Post 302795459 by balajesuri on Wednesday 17th of April 2013 09:27:11 PM
Old 04-17-2013
Code:
echo "Initialising the run time parameter for FOLDER path..."
cd $path   #path will be given here
echo "\n Folder path of the unzipped files and CNTRL file: $1 "
echo "\n \n Reading the content from CNTRL file and asssigning the values to variables..."
while IFS='|' && read fname Process_dt rec_cnt 
do
 echo "\n $fname $Process_dt $rec_cnt "
 echo "\n Checking if the File exist in the folder..."
 if [ -f $fname ]  ; then    
  echo "\n $fname Exist"
  echo "\n \n Reading linecount for the corresponding file and storing it in a variable..."
 
  linecount=$(wc -l $fname | cut -d' ' -f1)
  echo "\n Reading Processdate for the corresponding file and storing it in a variable..."
  Proc_dt=$(stat -c %y $fname | awk -F'[- ]' '{print $2 "/" $3 "/" $1}'
  echo "\n checking if record count and Process date of the file matches with the CNTRL file entry..."
   if [ $linecount -eq $rec_cnt && $Proc_dt -eq $Process_dt ]  ; then  
     echo "\n \n Record Count and Process date matches from both files"
     return 0  
   else 
     if [ $linecount -ne $rec_cnt ] # A space was missing between rec_cnt and ]
      echo "\n \n Record Count doesnot match"
      return 1
     fi
   else
     echo "\n \n Process date doesnot match" 
     return 1
   fi
 fi
 echo "Passing the run time parameter for CNTRL file name..."
done < POR.CRTl

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing data in file with values in table

Hi, I want to calculate the number of pipe delimiters in a file for all lines seperately. For eg:i have a file Project.txt Mohit|chawla|123|678 File1|File2|345|767|678 And my file contains many lines like this it shd give me the output as 4 5 or give me the output for all the... (0 Replies)
Discussion started by: Mohit623
0 Replies

2. Shell Programming and Scripting

Comparing data inside file

Hi Everyone, I will try to explain my question please forgive my english here. I am looking for shell script or command that can compare data in the files. I have 50 files in one directory test1 test2 test3 ....so on. I want to compare data in each files with each other and output each... (4 Replies)
Discussion started by: email-lalit
4 Replies

3. Shell Programming and Scripting

Need help in comparing a file with log file: perl code

Dear Members, I need a perl code: 1. Which will open first file with two columns separated by tab: 37 Distribution and seasonal variation of trace metals 85 Seasonal variability of the mixed layer in the central Bay 99 Dynamics of transparent exopolymeric particles (TEP) 103 Bacterial... (0 Replies)
Discussion started by: srsahu75
0 Replies

4. Shell Programming and Scripting

Comparing rows in same file and writing the result in new file

Help needed... Can you tell me how to compare the last two couple entries in a file and print their result in new file..:confused: I have one file Check1.txt \abc1 12345 \abc2 12327 \abc1 12345 \abc2 12330 I want to compare the entries in Check1 and write to... (1 Reply)
Discussion started by: kichu
1 Replies

5. Shell Programming and Scripting

Remove duplicate lines from first file comparing second file

Hi, I have two files with below data:: file1:- 123|aaa|ppp 445|fff|yyy 999|ttt|jjj 555|hhh|hhh file2:- 445|fff|yyy 555|hhh|hhh The records present in file1, not present in file 2 should be writtent to the out put file. output:- 123|aaa|ppp 999|ttt|jjj Is there any one line... (3 Replies)
Discussion started by: gani_85
3 Replies

6. UNIX for Dummies Questions & Answers

Mapping a data in a file and delete line in source file if data does not exist.

Hi Guys, Please help me with my problem here: I have a source file: 1212 23232 343434 ASAS1 4 3212 23232 343434 ASAS2 4 3234 23232 343434 QWQW1 4 1134 23232 343434 QWQW2 4 3212 23232 343434 QWQW3 4 and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies

7. Shell Programming and Scripting

Retrieve data from one file comparing the ID in the second file

Hi all, I have one file with IDs Q8NDM7 P0C1S8 Q8TF30 Q9BRP8 O00258 Q6AWC2 Q9ULE0 Q702N8 A4UGR9 Q13426 Q6P2D8 Q9ULM3 A8MXQ7 I want to compare ID file with another file which has complete information about these IDs and also about other IDs which are not in the above ID file. As... (10 Replies)
Discussion started by: kaav06
10 Replies

8. Shell Programming and Scripting

Script for Comparing directories and file from a text file

Hello all, I need to write a script which has following requirement: Need to read the filenames from text file and then search for the above read files in the required directory and if match found backup them in a backup folder. And also need to compare and verify whether the files in the... (7 Replies)
Discussion started by: saurau
7 Replies

9. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

10. UNIX for Dummies Questions & Answers

Comparing 2 column of a file with the lines in another file

Hi I have 2 files which are tab delimited. file1 chr1 5 10 P1 KR4 chr1 10 20 1H LA1 R0 TA1 file2 P1 G6 13.27 0.2425 P1 KR4 18.79 0.3060 P1 DND1 19.44 0.2833 N1 DH1 0.99 1.08 1H R0 0.9 NA LA1 R0 90 0.9 TA1 KR4 1.8 8.9 TA1 R0 9.7 99I want to check whether first 2 columns in file2 (column... (1 Reply)
Discussion started by: raj_k
1 Replies
bart(1M)						  System Administration Commands						  bart(1M)

NAME
bart - basic audit reporting tool SYNOPSIS
/usr/bin/bart create [ -n] [-R root_directory] [-r rules_file | -] /usr/bin/bart create [-n] [-R root_directory] -I [file_name]... /usr/bin/bart compare [-i attribute ] [-p] [-r rules_file | -] control-manifest test-manifest DESCRIPTION
bart(1M) is a tool that performs a file-level check of the software contents of a system. You can also specify the files to track and the types of discrepancies to flag by means of a rules file, bart_rules. See bart_rules(4). The bart utility performs two basic functions: bart create The manifest generator tool takes a file-level snapshot of a system. The output is a catalog of file attributes referred to as a manifest. See bart_manifest(4). You can specify that the list of files be cataloged in three ways. Use bart create with no options, specify the files by name on the command line, or create a rules file with directives that specify which the files to monitor. See bart_rules(4). By default, the manifest generator catalogs all attributes of all files in the root (/) file system. File systems mounted on the root file system are cataloged only if they are of the same type as the root file system. For example, /, /usr, and /opt are separate UFS file systems. /usr and /opt are mounted on /. Therefore, all three file systems are cataloged. However, /tmp, also mounted on /, is not cataloged because it is a TMPFS file system. Mounted CD- ROMs are not cataloged since they are HSFS file systems. bart compare The report tool compares two manifests. The output is a list of per-file attribute discrepancies. These discrepancies are the differences between two manifests: a control manifest and a test manifest. A discrepancy is a change to any attribute for a given file cataloged by both manifests. A new file or a deleted file in a manifest is reported as a discrepancy. The reporting mechanism provides two types of output: verbose and programmatic. Verbose output is localized and presented on multiple lines, while programmatic output is more easily parsable by other programs. See OUTPUT. By default, the report tool generates verbose output where all discrepancies are reported except for modified directory timestamps (dirmtime attribute). To ensure consistent and accurate comparison results, control-manifest and test-manifest must be built with the same rules file. Use the rules file to ignore specified files or subtrees when you generate a manifest or compare two manifests. Users can compare manifests from different perspectives by re-running the bart compare command with different rules files. OPTIONS
The following options are supported: -i attribute ... Specify the file attributes to be ignored globally. Specify attributes as a comma separated list. This option produces the same behavior as supplying the file attributes to a global IGNORE keyword in the rules file. See bart_rules(4). -I [file_name...] Specify the input list of files. The file list can be specified at the command line or read from standard input. -n Prevent computation of content signatures for all regular files in the file list. -p Display manifest comparison output in ``programmatic mode,'' which is suitable for programmatic parsing. The output is not localized. -r rules_file Use rules_file to specify which files and directories to catalog, and to define which file attribute discrepancies to flag. If rules_file is -, then the rules are read from standard input. See bart_rules(4) for the definition of the syntax. -R root_directory Specify the root directory for the manifest. All paths specified by the rules, and all paths reported in the manifest, are relative to root_directory. Note - The root file system of any non-global zones must not be referenced with the -R option. Doing so might damage the global zone's file system, might compromise the security of the global zone, and might damage the non-global zone's file system. See zones(5). OPERANDS
bart allows quoting of operands. This is particularly important for white-space appearing in subtree and subtree modifier specifications. The following operands are supported: control-manifest Specify the manifest created by bart create on the control system. test-manifest Specify the manifest created by bart create on the test system. OUTPUT
The bart create and bart compare commands write output to standard output, and write error messages to standard error. The bart create command generates a system manifest. See bart_manifest(4). When the bart compare command compares two system manifests, it generates a list of file differences. By default, the comparison output is localized. However, if the -p option is specified, the output is generated in a form that is suitable for programmatic manipulation. Default Format filename attribute control:xxxx test:yyyy filename Name of the file that differs between control-manifest and test-manifest. For file names that contain embedded whitespace or newline characters, see bart_manifest(4). attribute The name of the file attribute that differs between the manifests that are compared. xxxx is the attribute value from control- manifest, and yyyy is the attribute value from test-manifest. When discrepancies for multiple attributes occur for the same file, each difference is noted on a separate line. The following attributes are supported: acl ACL attributes for the file. For a file with ACL attributes, this field contains the output from acltotext(). all All attributes. contents Checksum value of the file. This attribute is only specified for regular files. If you turn off context checking or if checksums cannot be computed, the value of this field is -. dest Destination of a symbolic link. devnode Value of the device node. This attribute is for character device files and block device files only. dirmtime Modification time in seconds since 00:00:00 UTC, January 1, 1970 for directories. gid Numerical group ID of the owner of this entry. lnmtime Creation time for links. mode Octal number that represents the permissions of the file. mtime Modification time in seconds since 00:00:00 UTC, January 1, 1970 for files. size File size in bytes. type Type of file. uid Numerical user ID of the owner of this entry. The following default output shows the attribute differences for the /etc/passwd file. The output indicates that the size, mtime, and con- tents attributes have changed. /etc/passwd: size control:74 test:81 mtime control:3c165879 test:3c165979 contents control:daca28ae0de97afd7a6b91fde8d57afa test:84b2b32c4165887355317207b48a6ec7 Programmatic Format filename attribute control-val test-val [attribute control-val test-val]* filename Same as filename in the default format. attribute control-val test-val A description of the file attributes that differ between the control and test manifests for each file. Each entry includes the attribute value from each manifest. See bart_manifest(4) for the definition of the attributes. Each line of the programmatic output describes all attribute differences for a single file. The following programmatic output shows the attribute differences for the /etc/passwd file. The output indicates that the size, mtime, and contents attributes have changed. /etc/passwd size 74 81 mtime 3c165879 3c165979 contents daca28ae0de97afd7a6b91fde8d57afa 84b2b32c4165887355317207b48a6ec7 EXIT STATUS
Manifest Generator The manifest generator returns the following exit values: 0 Success 1 Non-fatal error when processing files; for example, permission problems >1 Fatal error; for example, invalid command-line options Report Tool The report tool returns the following exit values: 0 No discrepancies reported 1 Discrepancies found >1 Fatal error executing comparison EXAMPLES
Example 1 Creating a Default Manifest Without Computing Checksums The following command line creates a default manifest, which consists of all files in the / file system. The -n option prevents computation of checksums, which causes the manifest to be generated more quickly. bart create -n Example 2 Creating a Manifest for a Specified Subtree The following command line creates a manifest that contains all files in the /home/nickiso subtree. bart create -R /home/nickiso Example 3 Creating a Manifest by Using Standard Input The following command line uses output from the find(1) command to generate the list of files to be cataloged. The find output is used as input to the bart create command that specifies the -I option. find /home/nickiso -print | bart create -I Example 4 Creating a Manifest by Using a Rules File The following command line uses a rules file, rules, to specify the files to be cataloged. bart create -r rules Example 5 Comparing Two Manifests and Generating Programmatic Output The following command line compares two manifests and produces output suitable for parsing by a program. bart compare -p manifest1 manifest2 Example 6 Comparing Two Manifests and Specifying Attributes to Ignore The following command line compares two manifests. The dirmtime, lnmtime, and mtime attributes are not compared. bart compare -i dirmtime,lnmtime,mtime manifest1 manifest2 Example 7 Comparing Two Manifests by Using a Rules File The following command line uses a rules file, rules, to compare two manifests. bart compare -r rules manifest1 manifest2 ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWbart | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
cksum(1), digest(1), find(1), bart_manifest(4), bart_rules(4), attributes(5) NOTES
The file attributes of certain system libraries can be temporarily altered by the system as it boots. To avoid triggering false warnings, you should compare manifests only if they were both created with the system in the same state; that is, if both were created in single-user or both in multi-user. SunOS 5.11 26 Oct 2005 bart(1M)
All times are GMT -4. The time now is 04:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy