Help with AWK - Compare a field in a file to lookup file and substitute if only a match
I have the below 2 files:
1) Third field from file1.txt should be compared to the first field of lookup.txt.
2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt.
3)Else just print the line from file1.txt.
File1.txt:
lookup.txt :
Output file:
I tried giving this command, it returns only the matching values from File1.txt. Can someone help? ---------- Post updated at 01:21 PM ---------- Previous update was at 01:06 PM ----------
The above post,from user ahamed101 provides a solution
Last edited by Scrutinizer; 10-08-2012 at 04:47 PM..
Reason: code tags
First, thanks for the help in previous posts... couldn't have gotten where I am now without it!
So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following:
If $1... (4 Replies)
Hi,
I appreciate all who have been very helpful to me in providing valuable suggestions and replies.
I want to write a script to look up a file and match the contents. Let me go through the scenario. Lets say i have two files
Content file:
abc, bcd, adh|bcdf|adh|wed
bcf, cdf,... (2 Replies)
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Hi All,
I don't know how to fast do this field replace that need lookup from another file to form the update result:confused:
I want to do it by general shell script
Can anyone help to solve it ? Thanks for your kindly reply in advance.
CK (0 Replies)
Hi,
I have two questions which I would massively appreciate help with.
1.
I am trying to insert a field into a file similar to the vlookup function in excel. In column 2 is a gene id for which i would like to insert the full name in the adjacent column. I have a map file (map.file) which... (1 Reply)
not getting anywhere with this
an xml file contains multiple clients set up with same tags, different values.
I need to parse the file for client foo, and change the value of tag "64bit" from false to true.
cat clients.xml
<Client type"FIX">
<ClientName>foo</ClientName>... (3 Replies)
If $1 in file1 matches $2 in file2. Then the value in $2 of file2 is updated to $1"."$2 of file2. The awk seems to only match the two files but not update. Thank you :).
awk
awk 'NR==FNR{A ; next} $1 in A { $2 = a }1' file1 file2
file1
name version
NM_000593 5
NM_001257406... (3 Replies)
The below awk uses $3 and $4 in search as the min and max, then takes each $2 value in lookup and compares it. If the value in lookupfalls within the range in searchthen it prints the entire line in lookup/ICODE]. What I can't seem to figure out is how to print the matching $5 from search on that... (4 Replies)
I am trying to use awk to match two files that are tab-delimited. When a match is found between file1 $1 and file2 $4, $4 in file2 is updated using the $2 value in file1. If no match is found then the next line is processed. Thank you :).
file1
uc001bwr.3 ADC
uc001bws.3 ADC... (4 Replies)
I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file.
I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies
LEARN ABOUT LINUX
gitnamespaces
GITNAMESPACES(7) Git Manual GITNAMESPACES(7)NAME
gitnamespaces - Git namespaces
SYNOPSIS
GIT_NAMESPACE=<namespace> git upload-pack
GIT_NAMESPACE=<namespace> git receive-pack
DESCRIPTION
Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD. Git can
expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to
operations such as git-gc(1).
Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when
storing multiple branches of the same source. The alternates mechanism provides similar support for avoiding duplicates, but alternates do
not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do.
To specify a namespace, set the GIT_NAMESPACE environment variable to the namespace. For each ref namespace, Git stores the corresponding
refs in a directory under refs/namespaces/. For example, GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/. You can also specify
namespaces via the --namespace option to git(1).
Note that namespaces which include a / will expand to a hierarchy of namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under
refs/namespaces/foo/refs/namespaces/bar/. This makes paths in GIT_NAMESPACE behave hierarchically, so that cloning with
GIT_NAMESPACE=foo/bar produces the same result as cloning with GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar. It also
avoids ambiguity with strange namespace paths such as foo/refs/heads/, which could otherwise generate directory/file conflicts within the
refs directory.
git-upload-pack(1) and git-receive-pack(1) rewrite the names of refs as specified by GIT_NAMESPACE. git-upload-pack and git-receive-pack
will ignore all references outside the specified namespace.
The smart HTTP server, git-http-backend(1), will pass GIT_NAMESPACE through to the backend programs; see git-http-backend(1) for sample
configuration to expose repository namespaces as repositories.
For a simple local test, you can use git-remote-ext(1):
git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
SECURITY
Anyone with access to any namespace within a repository can potentially access objects from any other namespace stored in the same
repository. You can't directly say "give me object ABCD" if you don't have a ref to it, but you can do some other sneaky things like:
1. Claiming to push ABCD, at which point the server will optimize out the need for you to actually send it. Now you have a ref to ABCD and
can fetch it (claiming not to have it, of course).
2. Requesting other refs, claiming that you have ABCD, at which point the server may generate deltas against ABCD.
None of this causes a problem if you only host public repositories, or if everyone who may read one namespace may also read everything in
every other namespace (for instance, if everyone in an organization has read permission to every repository).
Git 1.8.5.3 01/14/2014 GITNAMESPACES(7)