Text not present in file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Text not present in file
# 1  
Old 06-29-2017
Text not present in file

File 1:
Code:
AAAAAA-100000 | ID: C110X01
AAAAAA-100000 | ID : P110X01
DDDDDD-8911694 | ID: P110X01



File2:-
Code:
------------------------------------------------------------------------
r1111111 | AAAAAA-100000 | 2011-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   A /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New Branch created
ID: C110X01
-----------------------------------------------------------------------
r2211111 | AAAAAA-100000 | 2011-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   M /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New branch created
ID: P110X01
-----------------------------------------------------------------------

r4111111 | BBBBBB-200000 | 2012-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   M /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New Branch created
 ID: D130X01
-----------------------------------------------------------------------
r3111111 |CCCCCC-300000 | 2013-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   A /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New Branch created
ID: E150X61
-----------------------------------------------------------------------

Moderator's Comments:
Mod Comment please use code tags as requested

Last edited by vbe; 06-29-2017 at 11:49 AM..
# 2  
Old 06-29-2017
And what is your question/issue?
# 3  
Old 06-30-2017
How to search content present in one file but not present in 2nd file

Hi Apologies for posting incomplete thread.

I have below question.

I have two file having below contents; I want to list out result which are present in file but not present in File 2 ,

Final result should display result from file1 look like this


Code:
AAAAAA-100000 | ID : Z110X01
DDDDDD-8911694 | ID: P110X01


File 1:

Code:
AAAAAA-100000 | ID: C110X01
AAAAAA-100000 | ID : P110X01
DDDDDD-8911694 | ID: P110X01


File2:-
Code:
-----------------------------------------------------------------------
r1111111 | AAAAAA-100000 | 2011-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   A /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New Branch created
ID: C110X01
-----------------------------------------------------------------------
r2211111 | AAAAAA-100000 | 2011-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   M /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New branch created
ID: P110X01
----------------------------------------------------------------------
r4111111 | BBBBBB-200000 | 2012-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   M /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New Branch created
 ID: D130X01
-----------------------------------------------------------------------
r3111111 |CCCCCC-300000 | 2013-06-16 11:47:33 +0530 (Fri, 16 Jun 2011) | 2 lines
Changed paths:
   A /home/india/V_26.00.00.00 (from /home/india/V_25.00.02.01:125142)

New Branch created
ID: E150X61
------------------------------------------------------------------------


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 06-30-2017 at 03:37 AM.. Reason: Added CODE tags.
# 4  
Old 06-30-2017
Still a bit sparse a specification. Try
Code:
awk 'NR==FNR {if (NF) T[$3 " | " $(NF-1) " " $NF]; next} !($0 in T)' RS="--+" file2 RS="\n" file1
AAAAAA-100000 | ID : P110X01
DDDDDD-8911694 | ID: P110X01

Tested on linux with exactly the samples given above - please be aware that your file1's data structure varies which may make the proposal fail.
This User Gave Thanks to RudiC For This Post:
# 5  
Old 06-30-2017
Thanks for your response .I have tried this code but no luck. it display all the record of File 1.

Code:
awk 'NR==FNR {if (NF) T[$3 " | " $(NF-1) " " $NF]; next} !($0 in T)' RS="---+" Modifed_results_26 RS="\n" M3


Moderator's Comments:
Mod Comment You were already asked to use code tags when posting code, data/logs etc. Please do so next time, thanks.

Last edited by zaxxon; 06-30-2017 at 07:44 AM.. Reason: code tags
# 6  
Old 06-30-2017
What's your result if you run it on the files given in post#1?
# 7  
Old 07-04-2017
I am getting below out after using code provided in tag1
Code:
AAAAA-100000 | ID: C110X01
AAAAAA-100000 | ID : P110X01
DDDDDD-8911694 | ID: P110X01


Last edited by vbe; 07-04-2017 at 03:59 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk code to find difference in second file which is not present in first file .

Hi All, I want to find difference between two files and output only lines which are not present in second file .I am using awk and I am getting only the first difference but I want to get all the lines which are not present in file2 .Below is the code I am using . Please help to get the desired... (7 Replies)
Discussion started by: srinivasrao
7 Replies

2. UNIX for Beginners Questions & Answers

UNIX script to append multiple text files into one file based on pattern present in filaname

Hi All-I am new to Unix , I need to write a script. Can someone help me with a requirement where I have list of files in a directory, I want to Merge the files if a pattern of string matches in filenames? AAAL_555A_ORANGE1_F190404.TXT AAAL_555A_ORANGE2_F190404.TXT AAAL_555A_ORANGE3_F190404.TXT... (6 Replies)
Discussion started by: Shankar455
6 Replies

3. Shell Programming and Scripting

Systemd errors of missing file “No such file or directory” inspite of file being present

The contents of my service file srvtemplate-data-i4-s1.conf is Description=test service for users After=network.target local-fs.target Type=forking RemainAfterExit=no PIDFile=/data/i4/srvt.pid LimitCORE=infinity EnvironmentFile=%I . . . WantedBy=multi-user.target (0 Replies)
Discussion started by: rupeshkp728
0 Replies

4. Shell Programming and Scripting

Speed : awk command to count the occurrences of fields from one file present in the other file

Hi, file1.txt AAA BBB CCC DDD file2.txt abc|AAA|AAAabcbcs|fnwufnq bca|nwruqf|AAA|fwfwwefwef fmimwe|BBB|fnqwufw|wufbqw wcdbi|CCC|wefnwin|wfwwf DDD|wabvfav|wqef|fwbwqfwfe i need the count of rows of file1.txt present in the file2.txt required output: AAA 2 (10 Replies)
Discussion started by: mdkm
10 Replies

5. Shell Programming and Scripting

Use sed to append text to filenames if text not already present

I have some html with hrefs that contain local links to pdf filenames. These filenames should have standardised names, i.e. there should be a label prior to the ".pdf" filename suffix. There can be many of these links on a single line of text and some may already have the label. For example ... (13 Replies)
Discussion started by: adb
13 Replies

6. Shell Programming and Scripting

Need unix commands to delete records from one file if the same record present in another file...

Need unix commands to delete records from one file if the same record present in another file... just like join ... if the record present in both files.. delete from first file or delete the particular record and write the unmatched records to new file.. tried with grep and while... (6 Replies)
Discussion started by: msathees
6 Replies

7. Shell Programming and Scripting

Delete a pattern present in file 2 from file 1 if found in file 1.

I have two files File1 ==== 1|2000-00-00|2010-02-02|| 2| 00:00:00|2012-02-24|| 3|2000-00-00|2011-02-02|| File2 ==== 2000-00-00 00:00:00 I want the delete the patterns which are found in file 2 from file 1, Expected output: File1 ==== (5 Replies)
Discussion started by: machomaddy
5 Replies

8. Shell Programming and Scripting

How to Check whether list file present in TXT file exist or not

Hi All, I have txt file which has list of files. I have to check whether these files exist or not. Thanks supriya (6 Replies)
Discussion started by: supriyabv
6 Replies

9. Shell Programming and Scripting

Help needed in extracting text present between two headers in .txt file

Hi All, Please help me out in fllowing problem. I have text file which contains the data in following format. Contents of file.txt are setregid02 Test that setregid() fails and sets the proper errno values when a non-root user attemps to change the real or effective... (2 Replies)
Discussion started by: varshit
2 Replies

10. Shell Programming and Scripting

ls > file - Creating file containing the list of all files present in a directory

Hi All, I need to create a file which contains the list of all the files present in that directory. e.g., ls /export/home/user/*.dat > list_file.dat but what i am getting is: $ ls /export/home/user/*.dat > list_file.dat /export/home/user/*.dat: No such file or directory But I have... (1 Reply)
Discussion started by: pranavagarwal
1 Replies
Login or Register to Ask a Question