The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Debian: doubt in "top" %CPU and "sar" output jaduks Debian 0 09-12-2007 09:05 AM
lsuser -c "ALL" - Output of this command Malar AIX 3 03-13-2007 07:52 AM
Maximum input file size in "Diff" Command Neeraja UNIX for Dummies Questions & Answers 1 01-17-2007 10:09 AM
diff on c-source file always returns "files differ" C-Prog-Man UNIX for Dummies Questions & Answers 7 08-31-2006 02:57 PM
Unix "at" / "Cron" Command New Problem...Need help Mohanraj UNIX for Dummies Questions & Answers 3 01-26-2006 08:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-28-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
reformat the output from "diff" command

Hi all,

I use the diff command and got the output:


Code:

$> diff -e file1.txt file2.txt
15a
000675695	Yi Chen	Chen	200520	EASY	50	2/28/05 0:00	SCAD Debit Card Charge
.
12a
000731176	Sarah	Anderson	200520	EASY	25	2/28/05 0:00	SCAD Debit Card Charge
.
11a
000624694	Meagan	Thomas	200520	EASY	402	2/28/05 0:00	SCAD Debit Card Charge
000679538	Nicole	Blackmon	200520	EASY	750	2/28/05 0:00	SCAD Debit Card Charge
.
2a
000679668	Ashley	Tucker	200520	EASY	200	2/28/05 0:00	SCAD Debit Card Charge
000672299	Candace	Daniels	200530	EASY	100	2/28/05 0:00	SCAD Debit Card Charge
.

How do i get rid of the line above the data?

I used "comm" and it works for the format, but sometimes it doens't give me the right results, maybe i change the .xls files to .txt files

Thanks

CT

Last edited by CamTu; 02-28-2005 at 05:52 PM..
  #2 (permalink)  
Old 02-28-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
If I understand your question correctly, you just want to be left with a the list of rows that need to be added to file1 in order to make it identical to file2, and you don't care about the actual position of these rows within the output (as you want to remove the 15a, 11a, etc...)?

If so, pass the output through sed

Code:
diff -e file1.txt file2.txt | sed -e '/^\.$/d' -e '/^[0-9][0-9]*a$/d'

This assumes that you all operations are "appends" (if not, modify the second sed expression to account for it), and that you don't want the rows containing just a "dot" (these are produced because of the -e option to diff which produces an "ed" script)....

If this doesn't help, please post sections of the two input files, and state exactly what results you are expecting to achieve (i.e. what exactly are you attempting to do?).

Cheers
ZB
  #3 (permalink)  
Old 02-28-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
zazzybob,

Thanks for your response, that's exactly what i am looking for
But i was just wondering, if i want the output in the actual position of these row within the output file, what is the code like? for instant, i want to get rid of those lines with 1a2,3, 4a7, 7a11, 10a15 and the ">" in front of the line.


Code:
$ > diff 1.txt 2.txt
1a2,3
> 000685115     Ariel   Wilchek 200520  EASY    150     2/28/05 0:00    SCAD Deb
it Card Charge
> 000686937     Charles Payne   200520  EASY    200     2/28/05 0:00    SCAD Deb
it Card Charge
4a7
> 000735567     Hayden  Lewis   200520  EASY    50      2/28/05 0:00    SCAD Deb
it Card Charge
7a11
> 000701166     Kyle    Provencal       200520  EASY    500     2/28/05 0:00
SCAD Debit Card Charge
10a15
> 000014514     Tiffany Jennings        200520  EASY    65      2/28/05 0:00
SCAD Debit Card Charge

Once again....thanks !

CT
  #4 (permalink)  
Old 03-01-2005
muthukumar muthukumar is offline
Registered User
  
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
Try as,

diff 1.txt 2.txt | sed '/^[0-9]a.*$/d;s/^>[ ]//'

HTH.
  #5 (permalink)  
Old 03-01-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100

Code:
diff file1.txt file2.txt | sed -e '/^[0-9][0-9a,]*$/d' -e 's/> //'

But you're still deleting the positional information, but this appears to be what you are requesting.

Cheers
ZB
  #6 (permalink)  
Old 03-01-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
hey guys,

Thanks alot.....

CT
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0