![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| checking ERRors in files | ali560045 | Shell Programming and Scripting | 4 | 06-19-2008 11:56 AM |
| how to login into another ip and checking for the files | saikumar_n | Shell Programming and Scripting | 2 | 07-11-2007 03:34 PM |
| how to login into another ip and checking for the files | saikumar_n | UNIX for Advanced & Expert Users | 1 | 07-11-2007 11:13 AM |
| checking for files on ftp... | jithinravi | UNIX for Dummies Questions & Answers | 3 | 06-22-2007 12:25 PM |
| Searching list of entries in file for actual files in dir | not4google | UNIX for Dummies Questions & Answers | 2 | 10-18-2006 12:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
checking entries between files
I need to write a script for:
I have two files where I need to check entries and sort of compare: file1: data01 data02 data03 data04 data05 . . . data81 file2: /vol/vx/data01 /vol/vx/data02 /vol/vx/data03 /vol/vx/data04 /vol/vx/data05 . . So each entry from file1 should have corresponding entry in file2. If entry exists it should pass but if there is no entry it should say: error: entry dataXXX has no entry in file2. Appreciate your help. |
|
||||
|
Quote:
I am getting the following error, "Unmatched '. when I executed the awk ' BEGIN {FS="/"} FNR==NR {arr[$0]=$0;next} {arr2[$4]=$4} END { for(i in arr) { if (!arr2[i]) { print "error: entry " arr[i] " has no entry in file2" } } }' "file1" "file2" Please let me know why so. I have a tcsh shell Thanks Amit |
|
||||
|
awk
Hi,
I tried this one and it works. input: Code:
a: data01 data02 data03 data04 data05 b: /vol/vx/data03 /vol/vx/data01 Code:
error: entry data04 has no entry in file2. error: entry data05 has no entry in file2. error: entry data02 has no entry in file2. code: Code:
sed 's/\// /g' b > b.tmp
nawk '
NR==FNR {a[$1]=$1}
NR!=FNR {a[$3]=$0}
END{
for (i in a)
if (i==a[i])
print "error: entry "i" has no entry in file2."
}
' a b.tmp
rm b.tmp
|
|
||||
|
awk
input:
Code:
a: data01 data02 data03 data04 data05 b: /vol/vx/data01 /vol/vx/data02 /vol/vx/data05 Code:
No entry for:data03 No entry for:data04 Code:
nawk 'BEGIN{FS="/"}
{
if (NR==FNR)
test[NR]=$4
else
{
flag=0
for (i in test)
{
if ($1==test[i])
flag=1
}
if (flag==0)
print "No entry for:"$1
}
}' b a
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|