General :: Comparing Two Fields In Two Files Using Awk?
Jul 12, 2011
I have a file1:
Code:
$ cat PF(1).out
Tmp39 PF10271.3 423 ENSP00000326063 488 1.2e-201 41-478
Tmp39 PF10271.3 423 ENSP00000338165 492 1.9e-200 46-479
[code].....
View 14 Replies
ADVERTISEMENT
Mar 20, 2010
I am fairly new to Linux and was needing some help on a comparing more than 2 files. I am try to come up with something that would compare at least 10+ different files to a master file and give me an output of what is missing.
Example would be: a.txt, b.txt, c.txt, d.txt compare each of them to the master.txt file, than output the missing text for each file into new file.
I came across comm and diff commands, am I looking in the right place or is there a much easier way of doing this?
View 2 Replies
View Related
Nov 5, 2010
Is there a way, besides writing a PERL program, to read each line one by one in file A and tell if this line also exists in file B? Can this be done via a shell script?
View 6 Replies
View Related
Sep 18, 2010
I wish to compare all the files in a directory....comparing is by content. And same files should be printed...
echo "program : $0"
cd $1
for a in *
do
[code]....
This logic did not give the correct result...
View 5 Replies
View Related
Sep 2, 2010
I want to compare two files and display values unique to file1. I tried using comm but it did not give me useful outputs.
comm -2 -3 file1 file2 does not work
Similar threads provide matched content. What I am looking for is unique content.
View 9 Replies
View Related
Jul 26, 2010
Iam having the following two linux files.
[Code]...
Now i want the following out puts
1. similar nos in both the file 1 and file 2 > output= File 3;
2. In file 1, but not in file 2 > out put= file 4;
3. In file 2, but not in file 1 > output = file 5;
The command sdiff is giving output with symbols > < | etc, and the such output file is not clear and ready to print. I want to print directly the output files. AND ALSO TELL ME WHERE I HAVE TO WRITE AWK PROGRAMS AND HOW TO RUN IT.
View 5 Replies
View Related
Nov 8, 2009
Two files contain:
file1:
cat
dog
fish
hamster
file2:
cat
fish
ferret
dog
How do you change the case of the letters in file1.txt to uppercase and compare with file2 all in one command?
View 2 Replies
View Related
Sep 17, 2009
Im trying to compare two files and I only want to display the user names that are in the first file and not the second.
So I have one file named final.txt (which contains every user name and only the user names in a list no other information)
Then I have another file Over1.txt (which only contains certain users that have different permissions This file is also setup differently with the user name and some information about the user after the user name.
I need a way to compare final.txt to over1.txt so that I will only display the names that are in final.txt but not Over1.txt
Ive tried using diff and comm but just cant seem to get it two work correctly. Im not sure if im missing a option or what.
View 5 Replies
View Related
May 7, 2011
I have two files
Code:
we have to consider here $5 , $6 , $7 for our search
file2.txt
Code:
Here we should take only $2 for comparison. As you can most of the $2 field records has value and some do not have value.
Question:I want to take the fields $5 , $6 , $7 from file 1 and compare it with $2 field from file 2. and the rsult should be like this:
Code:
The final output will look like this
Actual file1.txt (before running the code)
Code:
FIle1.txt after running the above said condition
Code:
So the field $5 , $6 , $7 should get replaced from the matched valued of $1(file1)
View 3 Replies
View Related
Jul 16, 2011
Dear expertsI have files like
ABD : 5869 events, relative ratio : 1.173800E-01 , sum of ratios : 1.173800E-01
VBD : 12147 events, relative ratio : 2.429400E-01 , sum of ratios : 3.603200E-01
SDF : 17000 events, relative ratio : 3.400000E-01 , sum of ratios : 7.003200E-01
[code]....
View 3 Replies
View Related
Jul 7, 2010
What's the command for comparing files? I think I've used it before, but can't remember it.
View 3 Replies
View Related
Nov 30, 2010
I have two text files i want to compare the differances between but i dont wnat all of them, there is only about 30lines of relvent text i want to compare.
View 10 Replies
View Related
Oct 9, 2009
I would like to ask opinion from perl experts.
I want to compare 2 files and show the differences in a text file.
For example, if i open File A an B in notepad
File A:
File B:
Quote:
line3 is missing in File B
So if I did a File compare (line by line), the differences will be in line3, line4, line5, line 6.
But I dont want it to be like that.
I want it to be like this
Quote:
Can Text:: Diff able to perform the work.
View 1 Replies
View Related
Jun 13, 2010
I've got an interesting challenge for the shell scripting wizards here. I've got a mySQL dump of three files for my amarok database with the intention of copying some files to my media server (cover art) so that I can keep the server the server and not rely on my local machine.
Step 1: Identify any cover art files on my local machine.
I did this with:
Code:
mysql -u amarok -p amarok -e "SELECT * FROM images WHERE path like '%.kde%'" > cover_art.txt
Output looks like this:
[Code]....
What I have here now is the ENTIRE album list in my collection -- and something to compare the IDs in Step 1 against. I'm going to stop here and will update the thread as I get past this stumbling block. "ID" in cover_art.txt = "image" in albums.txt... straightforward enough, right?
So the question is this: how do I create a simple shell script that will loop through the IDs in cover_art.txt (i.e. characters 0 -> 4 -- it will always be a 4 digit ID) and then search for that ID in the Albums.txt file.
View 3 Replies
View Related
Apr 13, 2011
I have 2 very long files which are quite similar:
file1.csv:
Code:
file2.csv:
Code:
I need this output:
Code:
explanation:
If the fields 3 (serie) and 4 (modello) are identical, the lines of the 2 files should be "added":
Code:
If the fields 3 (serie) and 4 (modello) are different, just print the line of both files:
Code:
Is there a way to do this without reading the (huge) files with a "while read line" loop?
View 14 Replies
View Related
Apr 6, 2011
Fedora 15 Alpha
3861 user 20 0 904m 128m 33m S 0.7 6.4 1:11.52 xulrunner-bin
1323 user 20 0 1555m 95m 31m S 13.5 4.8 4:06.87 gnome-shell
3494 user 20 0 1028m 50m 21m S 12.8 2.5 1:43.32 evolution
I just wondering what is the difference between RES, SHR, and VIRT.
1) The VIRT always seems to be higher. Is this using the paging file system. (virtual memory on the harddisk, the swap memory)
2) Is the RES memory the actual physical RAM memory?
3) Is shared memory sharing memory with other processes?
4) Just a final question. As I am running on a HP Mini 210, memory and CPU is a resource I don't have a abundence of. So if was to compare for example 2 difference browsers i.e. firefox and midora. What should I brench mark between to 2 to find what one uses less resources?
View 2 Replies
View Related
Feb 7, 2011
I'm trying to use awk to remove rows that are duplicates based on 3 fields, and I want to keep the on that has the higher value in another field. I'm working in C-Shell. For example the below is greped out of a larger data set to use in here as example:
Input (Field separator is a comma:
Code:
4180,-6999,MA,BARNSTABLE,BOURNE,1,1.7,1700,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,3.5,2025,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,1.0,1511,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,5.7,0540,AM,1/27
[Cpde]....
View 1 Replies
View Related
Mar 28, 2010
I'm writing a script that picks out the time offset in a string, but am trying to figure out a way to print a field based on a match (likely needs to be regex).
Here are some sample fields:
09.900. Either add -12:-1: 0 to existing offset, or restart the slicer with no offset or with offset=00
09.900. Either add -12:-1:30 to existing offset, or restart the slicer with no offset or with offset=00
09.900. Either add -10: 0:-47 to existing offset, or restart the slicer with no offset or with offset=00
What I need would be "-12:-1: 0" from the first line, for example. I was just using "awk '{print $4}'" originally but because of the damn space in the 1st and 3rd lines by the 0, that doesn't work for me. How to grab those fields correctly for all cases?
View 3 Replies
View Related
Feb 22, 2010
I'm looking for a way to dynamically modify a fied in the SQL file.
Example,
INSERT INTO `TABLE` VALUES(1AADFDF,DFF33D,10023,SOMEDATA, SOMEDATA);
INSERT INTO `TABLE` VALUES(1AADFDF,DFF33D,10098,SOMEDATA, SOMEDATA);
[code]....
The third field in this SQL file is what needs to change to n+1
"10023" needs to change to "1"
"10098" needs to change to "2"
"10123" needs to change to "3"
"10983" needs to change to "4"
etc...
I tried with awk and sed, but since both require the usage of ' (single quote), my variable fails to get updated. I know i can use cut and recreate the sql statememnt, but i believe there should be easier way using sed or awk. Would anyone know of any creative way to get this to work in one-liner? This needs to be a part of the script preferable without making call to external file.
View 1 Replies
View Related
Jun 2, 2010
Is there a way to compare an array in a while conditions?
I have one array that contains the results of some search and if the script has found all the items, then it should stop, so my idea is to have a while loop � la:
Code:
View 4 Replies
View Related
Dec 13, 2010
For example: file a:Tom:blackLily:pinkfile b:Tom:bigKate:smallAnd, the result:join -t: a1 a ot:Tom:black:bigLily:pinkBut what I want is:Tom:black:bigLily::pink
View 2 Replies
View Related
Jan 10, 2011
I have a couple of MP3s that have duplicate fields in their ID3 tags. Let me show you what I mean: This is causing problems with some media players. Is there a tool that can automatically fix these MP3s in batch? I'd prefer a free Windows or Linux program. I'm not afraid to work on the command line if necessary.
View 2 Replies
View Related
Jul 26, 2011
I'm trying to write a script that takes two arguments, the first argument is a number, and the second argument is a filename. The shell script should indicate if the file's size is BIGGER or SMALLER the number provided. this is what i have sofar, am i on the write track, i'm hoping its just a problem with my if command
if [ $1 -h $2 ]
then
echo "$1 is bigger than $2"
else
[code]....
View 2 Replies
View Related
Dec 2, 2010
I am trying to remove the space between the 2nd and 3rd fields but just cannot work out how to do it. I've considered sed, cut, awk...I know with sed you can replace all instances within a file but can you also specify to remove, say, the 2nd instance of a space in each line (this would be perfect for me)?
DAAE 60 402 Bejaia Algeria 1 36-43N 005-04E 36-43N 005-04E 2 2 P
DAAG 60 390 Dar-El-Beida Algeria 1 36-43N 003-15E 36-43N 003-15E 25 25 P
DAAJ 60 670 Djanet Algeria 1 24-33N 009-28E 24-33N 009-28E 1054 1054 P
[code]...
View 3 Replies
View Related
Jul 4, 2010
I have recently backed up all my documents photos etc to an external hard drive. What is the best way to check that everything has copied? I have tried diff but it was not very clear.
View 7 Replies
View Related
Nov 19, 2010
what new features in RHEL6 comparing to its older versions??
View 4 Replies
View Related
Feb 26, 2011
I have following in cpuinfo:
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
[code]....
View 2 Replies
View Related
Mar 12, 2011
comparing multiple items or conditions using 'if' statements? I want to do something if one or more conditions is true, for example:
If a = 1 or b = 1.
I've tried:
[Code]...
View 5 Replies
View Related
Mar 17, 2011
I have a tab delimited file with 2 columns.
2224 23943843
5494 39843843
8372 48938384
I have to loop through this file and copy the files with the first field to a new name that contains both the first and second field. To be more specific, file quote2224.pdf has to be copied to 23943843_quote2224.pdf file quote5494.pdf has to be copied to 39843843_quote5494.pdf I don't know how or if it's even possible to use a for loop and access both fields. I don't know how to copy files in awk.
View 1 Replies
View Related
Sep 1, 2010
I have a mytext file with month and year as two separate fields. likemytext fil
08 2010
09 2010
10 2010
........
........
........
I want to read the values of each field i.e., month and year into an awk script.
View 10 Replies
View Related