05-14-2013
Comparing 2 text files & downloading a file if the last lines are different
Hello I'm having a little difficulty in writing a shell script for a few simple tasks.
First I have two files "file1.txt" and "file2.txt" and I want to read and compare the last line of each file. The files look like this.
File1.txt
Quote:
major.number=7
minor.number=8
revision.number=0
build.number=696
File2.txt
Quote:
major.number=7
minor.number=8
revision.number=0
build.number=697
After comparing the two lines I would like the code to output which line has the higher number. Then depending on which file is outputted I would like to have the script download a file from a URL.
I figured out how to download a file from a URL but I couldn't figure out how to compare two lines and have them output to a variable that would then be used to determine what file to download. Thanks for listening to my ramblings. Any and all help is appreciated.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am comparing text files where there are number of rows of numbers from window to unix box
Is there any way of checking lets say 4 document of text file
and seeing the difference only (or missing rows of numbers)
with simple commands with lets say a batch file
FROM ABSOULTE... (2 Replies)
Discussion started by: sjumma
2 Replies
2. AIX
hi!
some looping problem here...
i have a 2-column text file
4835021 20060903FAL0132006
4835021 20060904FAL0132006
4835021 20060905FAL0132006
4835023 20060903FAL0132006
4835023 20061001HAL0132006
4835023 ... (3 Replies)
Discussion started by: d3ck_tm
3 Replies
3. Shell Programming and Scripting
Hi Friends,
I have 2 files A and B . I want to compare the 3rd line of file A and B .
(I dont want to compare the 2 files, using diff or cmp). I just want to know whether 3rd line of A matches the 3 rd line of B. Can anybody share their knowledge on the same?
Thanks ,
Vijaya (12 Replies)
Discussion started by: vijaya2006
12 Replies
4. Shell Programming and Scripting
Hi All,
I am a newbie to Shell scripting. Please help me with the Following problem,
1. I have two files with the same name in different locations in the same machine.
Eg: /root/testfolder/a ---- location 1
/tmp/testfolder/a ----- location 2
2. I want to compare the files in... (5 Replies)
Discussion started by: Karthick333031
5 Replies
5. Shell Programming and Scripting
Hi,
I have 2 files
file1
********
01-05-09|java.xls|
02-05-08|c.txt|
08-01-09|perl.txt|
01-01-09|oracle.txt|
********
file2
********
01-02-09|windows.xls|
02-05-08|c.txt|
01-05-09|java.xls|
08-02-09|perl.txt|
01-01-09|oracle.txt|
******** (8 Replies)
Discussion started by: shekhar_v4
8 Replies
6. Shell Programming and Scripting
Hello All,
I am writting file comparison Utility and I have encountered such a senario where there are 2 files such as follows-
1#!/usr/local/bin/python
2 import gsd.scripts.admin.control.gsdPageEscalate
3.gsd.scripts.admin.control.gsdPageEscalate.main()
1 #!/usr/local/bin/python... (10 Replies)
Discussion started by: Veenak15
10 Replies
7. Shell Programming and Scripting
Hi All,
I have two files of the following formats
file 1 - this is a big file
>AB_1 gi|229194403|ref|ZP_04321208.1| group II intron reverse transcriptase/maturase
gdfjafhlkhlnlklaklskckcfhhahgfahajfkkallalfafafa
>AB_2 gi|229194404|ref|ZP_04321209.1|
gfksjgfkjsfjslfslfslhf
>AB_3... (1 Reply)
Discussion started by: Lucky Ali
1 Replies
8. Shell Programming and Scripting
Hello,
Please help me with this problem if you have a solution.
I have two files:
<file1> : In each line, first word is an Id and then other words that belong to this Id
piMN-1 abc pqr xyz py12
niLM y12 FY4 pqs
fiRLym F12 kite red
<file2> : same as file1, but can have extra lds... (3 Replies)
Discussion started by: mira
3 Replies
9. Shell Programming and Scripting
I have 2 files of almost same text apart from 2,3 ending lines. Now I want to get that difference in another file.
e.g file1.txt is
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_livecd-lv_root
18G 2.4G 15G 14% /
tmpfs 504M ... (12 Replies)
Discussion started by: kashif.live
12 Replies
10. Shell Programming and Scripting
I dont even have a sample script cause I dont know where to start from. My data lookes like this
> sat#16 #data: 15 site:UNZA baseline: 205.9151
0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722
0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies
DIFF3(1) General Commands Manual DIFF3(1)
NAME
diff3 - 3-way differential file comparison
SYNOPSIS
diff3 [ -ex3 ] file1 file2 file3
DESCRIPTION
Diff3 compares three versions of a file, and publishes disagreeing ranges of text flagged with these codes:
==== all three files differ
====1 file1 is different
====2 file2 is different
====3 file3 is different
The type of change suffered in converting a given range of a given file to some other is indicated in one of these ways:
f : n1 a Text is to be appended after line number n1 in file f, where f = 1, 2, or 3.
f : n1 , n2 c Text is to be changed in the range line n1 to line n2. If n1 = n2, the range may be abbreviated to n1.
The original contents of the range follows immediately after a c indication. When the contents of two files are identical, the contents of
the lower-numbered file is suppressed.
Under the -e option, diff3 publishes a script for the editor ed that will incorporate into file1 all changes between file2 and file3, i.e.
the changes that normally would be flagged ==== and ====3. Option -x (-3) produces a script to incorporate only changes flagged ====
(====3). The following command will apply the resulting script to `file1'.
(cat script; echo '1,$p') | ed - file1
FILES
/tmp/d3?????
/usr/lib/diff3
SEE ALSO
diff(1)
BUGS
Text lines that consist of a single `.' will defeat -e.
Files longer than 64K bytes won't work.
DIFF3(1)