![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| diff file and previous version | bigboizvince | Shell Programming and Scripting | 1 | 03-26-2008 03:55 AM |
| Copy data and send it to other file, with diff config | single | Shell Programming and Scripting | 0 | 01-29-2008 06:56 AM |
| File Compare and Create New File with Diff | guiguy | UNIX for Advanced & Expert Users | 7 | 02-28-2007 03:43 AM |
| Help with multiple file rename - change case of part of file name | steve7 | UNIX for Dummies Questions & Answers | 7 | 06-30-2005 10:41 AM |
| diff 2 files; output diff's to 3rd file | blt123 | Shell Programming and Scripting | 2 | 05-28-2002 08:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello experts,
I have 2 files file1: lalalala good file file2: lblblblb good file these two files are the same in my test case, how can I start compare after certain number of characters? or is there a better way to do this? Thank you Last edited by minifish; 02-20-2008 at 09:49 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Are the files all in one line?
You ask about comparing files after a certain number of characters, so are you looking to ignore a fixed number characters on each line for each file? If those are the 'true' files, then a solution could be proposed. However, if there is more to the samples, it would be helpful to see. |
|
#3
|
|||
|
|||
|
Quote:
file1: lalalala good file lalblala good file lalalalb good file lalalbla good file file2: lblblblb good file lblblclb good file lblclblb good file lclblblb good file compare: #file1 and file2 are the same so I want to start compare after say 8 characters on every line in the two files. |
|
#4
|
||||
|
||||
|
I created two sample files (note I purposefully made a difference in the 2nd file calling something bad instead of good - to see some output from a diff command)
Code:
> cat tfile1 lalalala good file lalblala good file lalalalb good file lalalbla good file > cat tfile2 lblblblb good file lblblclb good file lblclblb good file lclblblb bad file Code:
> cat cfile #! /bin/bash f1="tfile1" f2="tfile2" f1out=$f1".out" f2out=$f2".out" cat tfile1 | cut -c10- >$f1out cat tfile2 | cut -c10- >$f2out diff $f1out $f2out Code:
> cfile 4c4 < good file --- > bad file |
|
#5
|
|||
|
|||
|
Quote:
I was stuck on it for so long. THANK YOU |
|
#6
|
|||
|
|||
|
one interesting thing is using "cat tfile1 | cut -c10- >$f1out "
tfile1 and f1out must be different. is there any way to replace the same file? what about "sed"? |
|||
| Google The UNIX and Linux Forums |