search for difference and find the above line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search for difference and find the above line
# 1  
Old 01-18-2011
search for difference and find the above line

hello All,

i have to two files package.today and package.yesterday , the extension of the files says what day the file belongs to .
contents of the file change little bit everyday .

i am taking only the package and sub package from the files
Code:
awk '/^[0-9+]/{print $0}' Packages.today
82                   
83                   
84                   
85                   
86                   
+--- 21
+--- 82
87                   
88                   
89                   
90                   
900                  
901                  
903                  
904                  
905                  
909                  
91                   
+--- 11
+--- PREVIEW PACKAGE
92                   
93                   
94                   
95                   
950                  
96                   
97                   
98                   
+--- 11
99

Code:
awk '/^[0-9+]/{print $0}' Packages.yesterday
82                   
83                   
84                   
85                   
86                   
+--- 21
+--- 82
87                   
88                   
89                   
90                   
900                  
901                  
903                  
904                  
905                  
909                  
91                   
+--- 11
92                   
93                   
94                   
95                   
950                  
96                   
97                   
98                   
+--- 11
99

The main package starts from the line begining and sub package begins with +--- , both the package names can be number and char


the difference between yesterdays and todays package list is
Code:
diff tmp.today tmp.yesterday | grep +--- | sed 's/<//g;s/+---//g;s/^ *//g'
PREVIEW PACKAGE

so "preview package" is a new sub package added in under the main package 91

i want to know the number what main package is the new sub package added ( here its is 91)

i may be following a longer path using diff command , all i want to know the main package number the sub package added,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search for word in huge logfile and need to continue to print few lines from that line til find date

Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
Discussion started by: Prathi
1 Replies

2. Shell Programming and Scripting

Search: find current line, then search back

Hello. I want to find a line that has "new = 0" in it, then search back based on field $4 () in the current line, and find the first line that has field $4 and "last fetch" Grep or Awk preferred. Here is what the data looks like: 2013-12-12 12:10:30,117 TRACE last fetch: Thu Dec 12... (7 Replies)
Discussion started by: JimBurns
7 Replies

3. UNIX for Dummies Questions & Answers

find Search - Find files not matching a pattern

Hello all, this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction. My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies

4. Shell Programming and Scripting

To find Difference

Hi Friends, I need to find the difference between two files , File_1 contained 4 columns, and File_2 contained 4 columns, I need to find the difference using 1st column, Or need to find the difference using 3st column, (6 Replies)
Discussion started by: Shenbaga.d
6 Replies

5. Shell Programming and Scripting

Find with in loops and then difference

Hi All, Please find my problem below: I have a file at two different nodes dev and test 1st find> find /u/dev/local/abc -name ab.dat --Since this file can be in several sub directories 2nd find> find /u/test/local/abc -name ab.dat I find my 1st find result and do compare with 2nd... (5 Replies)
Discussion started by: varun_bharadwaj
5 Replies

6. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

7. Shell Programming and Scripting

Line by Line Comparision of 2 files and print only the difference

Hi, I am trying to find an alternative way to do tkdiff. In tkdiff the gui compares each line and highlights only the differences. for eg: John works at McDonalds s(test) He was playing guitar tywejk John works in McDonalds 9908 He was playing guitar I am... (1 Reply)
Discussion started by: naveen@
1 Replies

8. Shell Programming and Scripting

Take each number in table row and find the difference from the corresponding line

I have a two files containing numbers like below. First one contains one number on each line, the other is a table of numbers, each separated by a space. There are the same number of lines in each file. I want to take each number in the row of the table and find the difference from the... (12 Replies)
Discussion started by: kristinu
12 Replies

9. Shell Programming and Scripting

search directory-find files-append at end of line

Hi, I have a command "get_data" with some parameters in few *.text files of a directory. I want to first find those files that contain this command and then append the following parameter to the end of the command. example of an entry in the file :- get_data -x -m50 /etc/web/getid this... (1 Reply)
Discussion started by: PrasannaKS
1 Replies

10. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
Login or Register to Ask a Question