Sponsored Content
Top Forums Shell Programming and Scripting Vlookup using awk non similar files Post 303015970 by RudiC on Tuesday 17th of April 2018 10:30:11 AM
Old 04-17-2018
Well, I don't think there's NEW challenges on vlookup (which, by the way, is an EXCEL or more generally, spread sheet function not available / applicable in *nix). They all are varieties of problems that have been solved for you recently, and you could juggle around with those to find a solution on your own, and post here if you're stuck.
Howsoever, how far would
Code:
awk '
FNR==NR {split ($1, T, "[_-]");
         SRV[T[1]]=$0
         next
        }
        {print (SRV[$1]?"":"notfound ") $0
        }

' file2 file1
server1
server2
server3
notfound server4
notfound server5_root
notfound server6_silver
server7
notfound server7-test
notfound server7-temp

get you?
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

vlookup files

hi frnds i have 2 files. 1st is dddd and 2nd is ssss ==> dddd <==: 1,charit 2,gilhotra ==> ssss <==: 1,sajan 2,doda 3,hello and i want o/p ...mean join and vlookup both files sajan,charit (4 Replies)
Discussion started by: dodasajan
4 Replies

2. Shell Programming and Scripting

Computing the ratio of similar columns in the two files using awk script

Thanks Bartus11 for your help in the following code to compare the two files "t1" and "t2". awk 'NR==FNR{a=1;next}$2 in a{print $2}' t1 t2 First can anyone explain that what is the purpose of assigning a =1? Second, the current script is printing out the matched columns between the... (4 Replies)
Discussion started by: coder83
4 Replies

3. Shell Programming and Scripting

Vlookup using awk

Hello, I am trying to use vlookup (Excel function) using awk but there is some problem :( --file1-- ABC123 101F X1 A $P=Z X2 A $P=X X3 B $P=F X4 C $P=G MNK180 END --file2-- X1 A_t $P=Z X2 A_t $P=X X3 B_u $P=F X4 C_o $P=G (2 Replies)
Discussion started by: young
2 Replies

4. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies

5. Shell Programming and Scripting

awk cmd for vlookup in Mysql

Hi, Is there possible to do vlookup in Mysql one table from another table based on one column values and placed the data in same table? if it is possible in mysql itself pls share links for reference. Here is the ex: i need to vlookup the cus.id in table to and place the cus.name in 4th... (3 Replies)
Discussion started by: Shenbaga.d
3 Replies

6. Shell Programming and Scripting

Vlookup using awk

Hi folks, awk 'NR==FNR {m=$0; next} $1 in m{$0=m} {print}' file2 file1 Works a charm for a vlookup type query, sourced from https://www.unix.com/shell-programming-and-scripting/215998-vlookup-using-awk.html However my column content has white spaces and numbers. Example file1 The Man... (6 Replies)
Discussion started by: pshields1984
6 Replies

7. Shell Programming and Scripting

Vlookup using awk without exact match

Code used to find the server from cloum 3 and update needtotakesnap Output came from above command awk 'NR==FNR{A;next}$3 in A{$3 = "needtotakesnap " $3}1' /home/Others/active-server.txt /home/Others/all-server |grep server1 879 dummy server1_217_silver dummy 00870 TDEV 2071575 831 Tier1... (3 Replies)
Discussion started by: ranjancom2000
3 Replies

8. UNIX for Beginners Questions & Answers

Vlookup on 2 files - inserting vlookup command on another command

Hello, i am trying to print group name column(etc/group) on script (etc/passwd) since group name is not listed on etc/passwd columns. Im trying to do a vlookup. but i cant figure out how i can insert the vlookup command FNR==NR inside the print out command or the output. I also tried exporting... (2 Replies)
Discussion started by: joonisio
2 Replies

9. UNIX for Beginners Questions & Answers

Vlookup not using awk

Hi I just want again to ask for help on what command to use to vlookup f1 group name in "/etc/group" matching f3 of it to "/etc/passwd" f4. I do need to display group name in the output of /etc/passwd without using awk or NR==FNR command. thank you while IFS=: read -r f1 f2 f3 f4 f5 f6 f7... (4 Replies)
Discussion started by: joonisio
4 Replies

10. UNIX for Beginners Questions & Answers

How to compare two files in UNIX using similar to vlookup?

Hi, I want to compare same column in two files, if values match then display the column or display "NA". Ex : File 1 : 123 abc xyz pqr File 2: 122 aab fdf pqr fff qqq rrr (1 Reply)
Discussion started by: hkoshekay
1 Replies
VOP_LOOKUP(9)						   BSD Kernel Developer's Manual					     VOP_LOOKUP(9)

NAME
VOP_LOOKUP -- lookup a component of a pathname SYNOPSIS
#include <sys/param.h> #include <sys/vnode.h> #include <sys/namei.h> int VOP_LOOKUP(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp); DESCRIPTION
This entry point looks up a single pathname component in a given directory. Its arguments are: dvp The locked vnode of the directory to search. vpp The address of a variable where the resulting locked vnode should be stored. cnp The pathname component to be searched for. Cnp is a pointer to a componentname structure defined as follows: struct componentname { /* * Arguments to lookup. */ u_long cn_nameiop; /* namei operation */ u_long cn_flags; /* flags to namei */ struct thread *cn_thread; /* thread requesting lookup */ struct ucred *cn_cred; /* credentials */ /* * Shared between lookup and commit routines. */ char *cn_pnbuf; /* pathname buffer */ char *cn_nameptr; /* pointer to looked up name */ long cn_namelen; /* length of looked up component */ u_long cn_hash; /* hash value of looked up name */ long cn_consume; /* chars to consume in lookup() */ }; Convert a component of a pathname into a pointer to a locked vnode. This is a very central and rather complicated routine. If the file sys- tem is not maintained in a strict tree hierarchy, this can result in a deadlock situation. The cnp->cn_nameiop argument is LOOKUP, CREATE, RENAME, or DELETE depending on the intended use of the object. When CREATE, RENAME, or DELETE is specified, information usable in creating, renaming, or deleting a directory entry may be calculated. Overall outline of VOP_LOOKUP: Check accessibility of directory. Look for name in cache, if found, then return name. Search for name in directory, goto to found or notfound as appropriate. notfound: If creating or renaming and at end of pathname, return EJUSTRETURN, leaving info on available slots else return ENOENT. found: If at end of path and deleting, return information to allow delete. If at end of path and renaming, lock target inode and return info to allow rename. If not at end, add name to cache; if at end and neither creating nor deleting, add name to cache. LOCKS
The directory, dvp should be locked on entry. If an error (note: the return value EJUSTRETURN is not considered an error) is detected, it will be returned locked. Otherwise, it will be unlocked unless both LOCKPARENT and ISLASTCN are specified in cnp->cn_flags. If an entry is found in the directory, it will be returned locked. RETURN VALUES
Zero is returned with *vpp set to the locked vnode of the file if the component is found. If the component being searched for is ".", then the vnode just has an extra reference added to it with vref(9). The caller must take care to release the locks appropriately in this case. If the component is not found and the operation is CREATE or RENAME, the flag ISLASTCN is specified and the operation would succeed, the spe- cial return value EJUSTRETURN is returned. Otherwise, an appropriate error code is returned. ERRORS
[ENOTDIR] The vnode dvp does not represent a directory. [ENOENT] The component dvp was not found in this directory. [EACCES] Access for the specified operation is denied. [EJUSTRETURN] A CREATE or RENAME operation would be successful. SEE ALSO
vnode(9), VOP_ACCESS(9), VOP_CREATE(9), VOP_MKDIR(9), VOP_MKNOD(9), VOP_RENAME(9), VOP_SYMLINK(9) HISTORY
The function VOP_LOOKUP appeared in 4.3BSD. AUTHORS
This manual page was written by Doug Rabson, with some text from comments in ufs_lookup.c. BSD
November 24, 1997 BSD
All times are GMT -4. The time now is 09:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy