Extracting lines present in one file but missing in another using Perl
Hey
I have an input file containing a list of numbers like:
And another input file containing results created on the basis of the above input:
The thing is that there should be one resultline pr input number but there are missing 77 lines(I checked this earlier in my program) in the resultfile. The following program I am writing to try and extract the numbers that doesn't result in an outputline since the files are too long to look through manually for the missing numbers.
I have put the numbers from the first line in one hash, %original, as keys and the first two lines of the second file in another hash, %results.
Now I reverse the two columns in %results. That way it's the keys in both hashes that I wanna compare.
The idea with the loop is to take the numbers in %original one by one and check if they are present in %results. If they are, I just wanna skip to check the next, but if a number is not present, I want it extracted and printed.
I only posted the part of the code that seems to not be working. But I have warnings and use strict turned on in the program.
Can anyone tell me where I go wrong in the above loop? I don't have much expertise using Perl or programming in general so I'm not sure if I'm using the 'unless ( exists' part correctly. Is this the right way to compare only keys without regards to the values?
Last edited by radoulov; 03-26-2010 at 08:19 AM..
Reason: Added code tags on the input data.
How can I extract few lines(like 10 to 15, top 10 and last 10) from a file using perl.
I do it with sed, head and tail in unix scripting. I am new to perl. Appreciate your help. (2 Replies)
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)
Hi
I have got two files
File1:
Row1
Row2
Row3
Row4
File2:
Row3
Row4
Now my requirement is search each and every line of file1 in file2 and if the record do not exist in file2 then write that to an output file.
Output file should be as below
Row1
Row2 (4 Replies)
Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,
19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
... (3 Replies)
Hi all
Thanks in advance...........
Please help me for this issue............
I have a file it has 11 records . I used the command like ....
>$ wc -l file
11 file
I'm getting output like 11 file (no.of records along with filename)
here my requirement is, I want to display only... (3 Replies)
Dear all,
I have a file with two columns - the first column is increasing every 50, the second column is just count (e.g. 5). However, when count is zero, no line is present.
Sample:
1950 7
2000 14
2050 7
2100 13
2150 10
2200 9
2250 7
2300 8
2350 7... (1 Reply)
Dear all,
I have a file with two columns - the first column is increasing every 50, the second column is just count (e.g. 5). However, when count is zero, no line is present.
Sample:
How can I change the file so as to include lines with zero count? e.g. in the previous file to put... (4 Replies)
I am getting the varible value from a grep command as:
var=$(grep "Group" File1.txt | sed 's/Group Name*//g;s/,//g;s/://g;s/-//g')
which leaves me the value of $var=xyz.
now i want to append $var value in the begining of all the lines present in the file. Can u please suggest?
Input file:
1... (10 Replies)
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
LEARN ABOUT HPUX
rpccp_import
import(1m)import(1m)NAME
import - Imports binding information and an object UUID from a server entry
SYNOPSIS
rpccp import starting-entry-name -i if-id [-v versions] [-e] [-n [ integer]] [-o object-uuid] [-s syntax] [-u]
OPTIONS
Defines an interface identifier to be imported (required). You can import only one interface at a time.
The value has the following form: interface-uuid,major-version.minor-version The UUID is a hexadecimal string and the version numbers are
decimal strings, for example: -i ec1eeb60-5943-11c9-a309-08002b102989,1.1 Leading zeros in version numbers are ignored. Indicates how a
specified interface version is used (optional). If it is used without the -i option, the -v option is ignored. The possible combinations
of versions for the -v option and their actions are as follows:
+-----------+-------------------------------------+
|Versions | Action |
+-----------+-------------------------------------+
|all | The interface version is ignored. |
|exact | Both the major and minor versions |
| | must match the specified versions. |
|compatible | The major version must match the |
| | specified version, and the minor |
| | version must be greater than or |
| | equal to the specified version. |
|major_only | The major version must match the |
| | specified version; the minor ver- |
| | sion is ignored. |
|upto | The major version must be less than |
| | or equal to that specified. If the |
| | major versions are equal, the minor |
| | version must be less than or equal |
| | to that specified. |
+-----------+-------------------------------------+
+-----------+-------------------------------------+
If the -v option is absent, the command shows compatible version numbers. Shows the name of the entry where the binding is found
(optional). Declares that the import operation is to continue until no more potential bindings are found (optional). Providing a numeric
value to this option restricts the number of imported bindings. If you omit the number, only one binding is imported. If repeated, this
operation may return the same binding.
For example, -n imports all available bindings, and -n 5 imports up to five bindings. Note that the imported bindings are displayed as
string bindings. Declares the UUID of an object to be imported (optional). Only one UUID can occur in a single operation.
If an object is specified, the import operation limits its search to server entries that contain both the specified interface identifier
and object UUID when searching for a potential binding. Without the -o option, the import operation ignores object UUIDs.
The UUID is a hexadecimal string, for example: -o 3c6b8f60-5945-11c9-a236-08002b102989
Indicates the name syntax of the entry name (optional). The only value for this option is the dce name syntax, which is the default name
syntax. Until an alternative name syntax becomes available, specifying the -s option is unnecessary. Updates the local CDS cache copy of
name service data (optional).
Name service data is cached locally on each machine in a cell. If an rpccp inquiry can be satisfied by data in the local CDS cache, this
cached data is returned. Locally cached copies of name service data might not include a recent CDS update, however. If the required data
is not available in the local CDS cache, rpccp goes to a CDS server(s) to retrieve the required data. rpccp then updates the local CDS
cache.
Using the -u option bypasses the local cache, allowing rpccp to go directly to a CDS server for the inquiry. rpccp then updates the local
CDS cache.
ARGUMENTS
Indicates the name of the server entry where the import operation starts. For an entry in the local cell, you can omit the cell name and
specify only the cell-relative name.
DESCRIPTION
The import command imports binding information and an RPC object UUID for a specific RPC interface from a server entry. The name of the
entry and the interface identifier are required. The entry name can refer to a server entry, a group, or a profile.
Privilege Required
You need read permission to the specified CDS object entry (the starting name service entry) and to any CDS object entry in the resulting
search path.
NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE.
EXAMPLES
The following commands run RPCCP and import an interface and object: $ rpccp rpccp> import -i ec1eeb60-5943-11c9-a309-08002b102989,1.1 >
-o 30dbeea0-fb6c-11c9-8eea-08002b0f4528 > /.:/LandS/anthro/Cal_host_3
RELATED INFORMATION
Commands: export(1m), show server(1m), unexport(1m)import(1m)