1

I have used diff command in past.I faced a situation to which I did not had a clue here are some text strings (which can be stored in a file)

CONFIG_XEN=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=128
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_SWIOTLB_XEN=y
CONFIG_MICROCODE_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_DOM0_PCI=y
CONFIG_XEN_PCI_PASSTHROUGH=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=m
CONFIG_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XEN_NETDEV_BACKEND=m
CONFIG_XEN_BLKDEV_BACKEND=m
CONFIG_XEN_BLKDEV_TAP=m
CONFIG_XEN_BLKBACK_PAGEMAP=m
CONFIG_XEN_PCIDEV_BACKEND=m
CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_MCE=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_S3=y
CONFIG_ACPI_PROCESSOR_XEN=y
CONFIG_XEN_PLATFORM_PCI=m

I have to basically find above strings only (not any other) in a .config file of kernel which looks as follows

http://pastebin.com/AEQ6p9Vm It is a very big file.

Now I had no clue if by commands I can find the entries I first mentioned whether exist in second file or not so I did manually copied each entry and searched in the .config I mentioned.I found

there are following differences

 # CONFIG_XEN_DEBUG_FS is not set CONFIG_XEN_BLKBACK_PAGEMAP <--- is
 completely missing
 # CONFIG_XEN_NETDEV_BACKEND is not set
 # CONFIG_XEN_BLKDEV_BACKEND is not set
 # CONFIG_XEN_BLKDEV_TAP is not set CONFIG_XENFS=y
 # CONFIG_XEN_GNTDEV is not set

Can this be easily done by find grep or some thing similar?

Registered User
  • 1,453
  • 5
  • 18
  • 37

2 Answers2

3

This will show the lines in the big file which match the lines in the list.

grep -Ff string-list-file very-big-file
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
2

First, sort your two files.

sort list > list-sorted
sort config > config-sorted

To see the lines that are in your list and in your config file, run

comm -1 -2 list-sorted config-sorted

To see the lines in your list that are not in your config file, run

comm -2 -3 list-sorted config-sorted

sciurus
  • 12,493
  • 2
  • 30
  • 49