LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2011, 03:35 AM   #1
alancampbell6
LQ Newbie
 
Registered: Jul 2011
Posts: 16

Rep: Reputation: Disabled
Compare 1 column bash


I generate a file everyday with three columns. I want my script to compare today's file with yesterdays file. It works currently but not the way i want it.the second and third column change every day but i dont want to know about that, i only want to know if the first column changes.

Here is the code that compares all columns and outputs the differences to a txt file.

grep -Fxvf $yesterday.txt $today.txt >> diff.txt

Does anyone know how to only compare the first column only??
 
Old 08-18-2011, 04:11 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Have you looked at diff or comm?
 
Old 08-18-2011, 04:16 AM   #3
alancampbell6
LQ Newbie
 
Registered: Jul 2011
Posts: 16

Original Poster
Rep: Reputation: Disabled
Yes but i grep was easier for this initially, now maybe diff would be better. any ideas?
 
Old 08-18-2011, 06:19 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Have a look at the man pages and see what you find
 
  


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
[SOLVED] How do I compare two arrays in bash? iBasher Linux - Newbie 6 10-02-2010 11:12 AM
Column manipulation in bash neo2k Linux - Newbie 3 03-19-2010 12:58 PM
Bash compare characters action_owl Programming 3 03-04-2010 08:13 AM
[Help me, plz!!] Compare string in the column in the file... nightmare520 Linux - Newbie 1 12-04-2009 06:40 AM
calculating average of a column of numbers in bash hta1984 Programming 4 12-13-2006 11:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:55 PM.

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