Sponsored Content
Top Forums Shell Programming and Scripting Compare two files and get only missing names Post 302865213 by Akshay Hegde on Friday 18th of October 2013 12:59:16 AM
Old 10-18-2013
Please use codetag

try

Code:
$ grep -v -f oldfile  newfile

OR

Code:
$ awk 'FNR==NR{A[$0]++;next}!($0 in A)' oldfile newfile

Resulting

Code:
North carolina
India
Switzerland

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding missing sequential file names

So, I've got a ton of files that I want to go through (ie something like 300,000), and they're all labeled sequentially. However I'm not 100% positive that they are all there. Is there any way of running through a sequence of numbers, checking if the file is in the folder, if not appending it... (2 Replies)
Discussion started by: Julolidine
2 Replies

2. Shell Programming and Scripting

Compare files in two folders and delete missing ones

I do not know much about shell scripting so I am at a loss here. If someone can help me, that would be great! I have two directories /dir1 /dir2 I need to delete all files from /dir1 and that does not have a correspondent file in /dir2. It should NOT check file suffixes in /dir2 . Why?... (20 Replies)
Discussion started by: kaah
20 Replies

3. Shell Programming and Scripting

Compare 2 folders to find several missing files among huge amounts of files.

Hi, all: I've got two folders, say, "folder1" and "folder2". Under each, there are thousands of files. It's quite obvious that there are some files missing in each. I just would like to find them. I believe this can be done by "diff" command. However, if I change the above question a... (1 Reply)
Discussion started by: jiapei100
1 Replies

4. Shell Programming and Scripting

Compare list [ names and size files ]

Hello, I've downloaded a huge amont of files I've got a list of files from a remote server. -rw-r--r-- 1 str661 strem 453465260 Dec 16 15:54 SATRYS2V1_20021218_temp_bias.nc -rw-r--r-- 1 str661 strem 17669468 Dec 16 18:01 SATRYS2V1_20021225_hdyn_bias.nc -rw-r--r-- 1... (9 Replies)
Discussion started by: Aswex
9 Replies

5. UNIX for Dummies Questions & Answers

how to compare names of files?

hi, can somebody tell me how to compare names of files? the situation is I have 2 files file1 and file2 and I want to figure out which file has the biggest ending, in this case file2 is. thank you (3 Replies)
Discussion started by: s3270226
3 Replies

6. Shell Programming and Scripting

Check for particular files and compare the file names

Hi, Below are the 2 files in directory /tmp: masterCSF242323.img indexCSF242323.img 1) I want to compare if both the number (242323) are same in both the files. If they are same print - Files matching, else print files do not match. 2) Also if only index file is present in that... (7 Replies)
Discussion started by: apatil65
7 Replies

7. Shell Programming and Scripting

Linux Script to compare two folders and copy missing files

Hi, I need help in shell scripting. If someone can help me, that would be great! Problem. I want Linux Script to compare two folders and copy missing files. Description. I have two directories /dir1 /dir2 I need to copy all distinct/new/unique/missing files from /dir1 and that... (1 Reply)
Discussion started by: S.Praveen Kumar
1 Replies

8. Shell Programming and Scripting

Compare two files containing package names and version number

I have 2 files each containing a list of same fedora packages but with different version number. I want to compare the 2 files and remove the lines containing a newer or older version number (1 Reply)
Discussion started by: asya18
1 Replies

9. Shell Programming and Scripting

Compare files with different names in different directories

Hi, I have a requirement to compare files in different directories with different names. The files have a datestamp in their name (It might not be a sequential datetimestamp). This is for Redhat Linux. I have more than 5 directories and more than 10 file in each directory to be compared. ... (4 Replies)
Discussion started by: GosarJunk
4 Replies

10. Shell Programming and Scripting

Compare 2 files and find missing fields awk

Hello experts! I have 2 files. file1 is a list file containing uniquely names. e.g.: name1 number number name2 number number name5 number number name10 number number ... file2 is a data file arbitrary containing the names of file1 in paragraphs separated by "10" e.g. name4 ... (3 Replies)
Discussion started by: phaethon
3 Replies
lucompare(1M)						  System Administration Commands					     lucompare(1M)

NAME
lucompare - compare boot environments SYNOPSIS
/usr/sbin/lucompare [-i infile | -t] [-o outfile] BE_name [-X] /usr/sbin/lucompare [ -C file [-o outfile]] [-X] DESCRIPTION
The lucompare command is part of a suite of commands that make up the Live Upgrade feature of the Solaris operating environment. See live_upgrade(5) for a description of the Live Upgrade feature. The lucompare command compares the contents of the current boot environment (BE) with the contents of another BE. With the -C option, lucompare compares file statistics so that you can determine which files have changed on a BE since a specified time, such as the creation time of a BE. A specified BE must be inactive and in the complete state, as reported by the lustatus(1M) command. Also, a BE cannot have a copy job scheduled, which is also reported by lustatus(1M). A specified BE cannot have any partitions mounted with lumount(1M) or mount(1M). For each file system defined for a specified BE, lucompare compares all files with the files with the same pathnames in the current BE. The files present in the active BE, but not in the specified BE, and vice-versa, are reported. You also have the option to specify a list of files to be compared. If you specify the -C option, instead of doing an absolute comparison of the current BE with a target BE, lucompare compares the files in a specified BE with the list of files recorded in a file. When a BE is created, lucreate(1M) creates a file named :<BE_name> in /etc/lu/com- pare. You can use the -C option to compare the files in a specified BE to this snapshot in /etc/lu/compare or you can compare the BE to a file previously created with the -o option. Comparing a BE to its own snapshot in /etc/lu/compare enables you to determine which files have changed on the BE since its creation. By default, the output of lucompare is written to stdout. With the -C option, you must use the -o option to specify an output file. The output for lucompare is a list of files that differ in permissions, owner, group, or sum, along with the reason for difference. The output format is shown below: > active BE < BE_name reason > file_name:owner:group:number_of_links:mode:type: size or major_minor number:checksum < file_name:owner:group:number_of_links:mode:type: size or major_minor number:checksum The above fields are obtained from the stat(2) structure of the file. The type field can be one of the following: SYMLINK symbolic link FIFO FIFO file CHRSPC character special BLKSPC block special DIR directory REGFIL regular file UNKNOW unknown file type lucompare computes checksums only if the file on the specified BE matches its counterpart on the active BE in all of the fields described above. If the checksums differ, lucompare appends the differing checksums to the entries for the compared files. The lucompare command requires root privileges. OPTIONS
The lucompare command has the following options: -C file Compare file statistics of BE with those recorded in file. file can be the snapshot created at BE creation time, /etc/lu/compare/:<BE_name>, or a file previously created with the -o option. You must use the -o option with this option. -i infile Compare files listed in infile. The files to be compared should be an absolute filename. If the entry in the file is a directory, then comparison is recursive with respect to the directory. Mutually exclusive of -t. -o outfile Send output of differences to outfile. You must use this option if you use -C. -t Compare only nonbinary files. This is achieved by performing a file(1) command on each file in the tree walk and only comparing text files. Mutually exclusive of -i. -X Enable XML output. Characteristics of XML are defined in DTD, in /usr/share/lib/xml/dtd/lu_cli.dtd.<num>, where <num> is the version number of the DTD file. OPERANDS
BE_name Name of the BE to which the active BE will be compared. You cannot specify a BE that is involved in another Live Upgrade operation, or specify a BE for which you have mounted partitions (using lumount(1M) or mount(1M)). EXAMPLES
Example 1: Checking Differences Since BE Creation The following command lists the differences in the BE s8u5 between its creation time and the present. # lucompare -C /etc/lu/compare/:s8u5 -o /var/tmp/compare.out s8u5 Note that /etc/lu/compare/:s8u5 is the file created by lucreate upon creation of a BE. The list of differences is sent to /var/tmp/com- pare.out. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/etc/lutab list of BEs on the system /usr/share/lib/xml/dtd/lu_cli.dtd.<num> Live Upgrade DTD (see -X option) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWluu | +-----------------------------+-----------------------------+ SEE ALSO
lu(1M), luactivate(1M), lucancel(1M), lucreate(1M), lucurr(1M), ludelete(1M), ludesc(1M), lufslist(1M), lumake(1M), lumount(1M), lure- name(1M), lustatus(1M), luupgrade(1M), lutab(4), attributes(5), live_upgrade(5) NOTES
The lucompare command makes no attempt to reconcile any differences it detects between BEs. SunOS 5.10 21 Dec 2001 lucompare(1M)
All times are GMT -4. The time now is 09:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy