LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-05-2018, 01:23 AM   #1
rajini23
Member
 
Registered: Sep 2011
Posts: 162

Rep: Reputation: Disabled
Unhappy File commparision


Hi,

I want to commpare to file and get missing lines out of it,
but it was not working, kindly assist on this issue..

file1:

dewdfg1234
vml123

file2:
DEWDFG1234
vml1245
vml23

out i should get here is:

vml1245

but i am getting:
vml1245
dewdfg1234 --> i should not get this because it is already there in two files one with CASE. but below commands it is not ignoring the case

comm -12 file1 file2
grep -v -f file1 file2
 
Old 04-05-2018, 02:06 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
normally i use "diff"

Code:
man diff


DIFF(1)                                                 User Commands                                                DIFF(1)



NAME
       diff - compare files line by line

SYNOPSIS
       diff [OPTION]... FILES

DESCRIPTION
       Compare FILES line by line.

       Mandatory arguments to long options are mandatory for short options too.

--- a long output edited out
 
Old 04-05-2018, 07:01 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by rajini23 View Post
Hi,
I want to commpare to file and get missing lines out of it, but it was not working, kindly assist on this issue..

file1:
dewdfg1234
vml123

file2:
DEWDFG1234
vml1245
vml23

out i should get here is:
vml1245

but i am getting:
vml1245
dewdfg1234 --> i should not get this because it is already there in two files one with CASE. but below commands it is not ignoring the case

comm -12 file1 file2
grep -v -f file1 file2
After being a member here for seven years now, you should be well aware that you need to do basic research first. As with the numerous other threads you've posted over the years wanting people to write scripts for you, this one also shows little effort.

You can either translate both files to all upper-case and do your comparison, or look at the man page on diff which will ignore case. Again, do basic research on your own first.
 
Old 04-07-2018, 07:33 AM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,791

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Try grep or fgrep with the -i option
Code:
fgrep -ivf file1 file2
For whole line matches (a12 should not match a123) there is -x option for fgrep.
Code:
fgrep -ixvf file1 file2
 
Old 04-10-2018, 12:00 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You can easily do it with diff, but note even ignoring case, you still have 2 differences, the one you 'want' and 'vml23' vs 'vml123' ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ls command to list out the file names,directory(along which file is present), file details(size,date time) at one go amala15vsa Linux - Newbie 1 10-09-2017 11:37 AM
Mencoder adds the extension of the original file to the output file ex: file.flv.mp4 linuxlicious Linux - General 2 04-17-2012 02:22 PM
Mencoder adds the extension of the original file to the output file ex: file.flv.mp4 linuxlicious Linux - General 1 04-15-2012 04:07 AM
How to play a media file/ video file/mp3 file recorded in harddisk/cd-rom arindam Linux - Newbie 2 09-05-2003 10:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration