I have written the shell script which does the following :
a. Reads the *.cnf file content from the specified input folder path
b. Grep's some strings from the *.cnf file and writes the output in result file(*.cnf_result.txt) in output folder
c. Now, if we get new version of config files, then will put new files in input folder and run the script again
d. First script checks if there is any output files already generated, if so then it archives those files and copies to archive path
e. After archiving, it run the same grep's command onto the new file and generates the new set of result file under result path
f. Then, it check if the same file present in the archive folder if so, it compares the new result file with archived result file and generate the new *.cnf_cmp.txt file
Now, the problem is with compare result file, since am using sdiff command(does line by line comparision), it prints both old file content and as well new file content side by side
and prints the symbols ( < > | ) in between if there is any difference found.
My question is,
1. Is there any better way/solution/approach/logic that we can do this
2.Can we add color codes to the lines present in the *.cnf_cmp.txt file so that, i will be easy to read/identify the changes.
like, if there is line found in old file which is not present in new, then mark that line in yellow color.. something like that.
Thanks for reading the post anyhelp is much appreciated.
Path :
Main script :
Last edited by jim mcnamara; 03-20-2013 at 09:19 AM..
Adding color is tricky, because the position of the gutter is dynamically determined. If you knew what is was and the escape sequences for your $TERM (which is color capable) then it is just a bit of post-processing. Maybe you should be looking for a GUI sdiff replacement, like the file comparison that came with my Borland Starteam.
Finding changes is easier if you change to a 'diff -u' format or 'diff -U99999', since the line prefix says what color to change it to. Easier to search for in text viewing tools, too.
Finding new/deleted/changed files might be faster using "comm -3 <( cd head1 ; find ... | xargs ... cksum | sort ) <( cd head2 ; find ... | xargs ... cksum | sort )|...."
Optimus81:
Please see this link on how to add colors to output of shell scripts. Aravindhan_D:
First, ksh is not a command per se, but a shell.
Second, this code snippet should at least get you started:
Please note that the code above makes the following assumptions:
1) The number of lines in a.txt is greater than the number of lines in b.txt.
2) To produced your desired output, all the lines in b.txt must appear in a.txt, so that only the lines that are in a.txt but not in b.txt will be redirected to diff.txt.
Hope it helps.
In the example below i would want the extensions to match.
Is there any other utility or script to achieve this. Kindly help.
Example:
sdiff sourceFileNames targetFileNames
17021701P.blf | 17021901P.ibk
17021701P.chn | 17021901P.irk
17021701P.bmr | 17021901P.dyd
17021701P.dpf |... (7 Replies)
Hello guys,
I have a problem. I'm trying to use SDiff with two files which are containing spaces.
My problem is that I want to save the output with > in an extra file.
If I try to use it like this.
sdiff "test file1" "test file2" > OutputfileI get this message:
usage: diff ... (11 Replies)
Hi
i am comparing file on 2 different machine with the help of script.
however i am get below o/p
======= /usr/tmp =========
======= /usr/tmp not a regular file i am not sure what does "not a regular file mean" .
is it something serious, if yes then what i need to check or we can... (1 Reply)
Hi All,
I am trying to run find command in a script to list out certain files based on a patter. However, when there is no file in the output, the script should exit.
Tried a couple of operators (-n, -z) etc but the script does not work.
I am confused whether a null string is returned... (3 Replies)
Hi All,
I have been surfing to get some idea on how to compare same files from two different paths.
one path will have oldfiles directory and another path will have newfiles directory. Each main directories will have sub-directories in them and
each sub-directories inturn will have... (3 Replies)
Hi,
I'm trying to use sdiff by parsing the output of another command instead of the filename:
sdiff <(echo test1) <(echo test2)However, this seems to cause my terminal session to stop working.
If I use it with normal diff it works fine:
~$ diff <(echo test1) <(echo test2)
1c1
< test1... (4 Replies)
I have four files, I need to compare these files together.
As such i know "sdiff and comm" commands but these commands compare 2 files together. If I use sdiff command then i have to compare each file with other which will increase the codes.
Please suggest if you know some commands whcih can... (6 Replies)
Hi,
I have two files, file1 and file2 and I need to compare them by line (exact match, order of the lines is not important) and get output with lines from file2 that are not found in file1 (not other way around).
How do I do that? With grep or otherwise..
Thankyou (2 Replies)
I have searched about 30 threads, a load of Google pages and cannot find what I am looking for. I have some of the parts but not the whole. I cannot seem to get the puzzle fit together.
I have three folders, two of which contain different versions of multiple files, dist/file1.php dist/file2.php... (4 Replies)
Hi,
I have a question of comparing to files and output
the result third file where file1 is the mainfile containing processed dir data
and 2nd file grepīs dirīs data again (could be newer dirs comparing file1<file2)
now i wanna make shure that output in file3 only contains newer dirs
hx... (1 Reply)