Sponsored Content
Top Forums Shell Programming and Scripting Need help comparing two files and deleting some things in those files! Post 302438851 by linuxkid on Wednesday 21st of July 2010 03:16:57 AM
Old 07-21-2010
Quote:
Originally Posted by citaylor
How about:

Code:
awk 'BEGIN{
    while ((getline < "two") > 0) {
        for(i=2;i < NF;i+=2) {
            refs[$1 "--" $i] = $(i+1)
        }
    }
}{
    out=""
    for(r in refs) {
        split(r, keys,"--")
        if(keys[1] == $1 && keys[2] >= $2 && keys[2] <= $3) {
            out=keys[2] " " refs[r] " " out
        }
    }
    printf("%s %s\n",$1,out)
}'

the second file has a hard-coded file name of "two" and you pipe file "one" into it.
When you say pipe the file into it, do you mean like
Code:
file1 | awk....

?

Last edited by linuxkid; 07-21-2010 at 04:24 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

comparing shadow files with real files

Hi I need to compare shadow file sizes with their real file counterparts. If the shadow file size differs form the realfile size then it must send a mail. My problem is that our system has over 1600 shadowfiles in different directories, with different names. the only consistancy is the .sh file... (4 Replies)
Discussion started by: terrym
4 Replies

2. UNIX for Dummies Questions & Answers

Deleting the files comparing the creation dates

Hi Gurus, I am new to unix. I have a requirement where i need to delete some files in a folder twice a week. Suppose i have a folder AAA. In that i have files from 01/04/2008 to 10/04/2008 I want to remove all the files except last 3 days i.e., 10,9th & 8th. Every week twice we want to... (2 Replies)
Discussion started by: pssandeep
2 Replies

3. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

4. Shell Programming and Scripting

Comparing the matches in two files using awk when both files have their own field separators

I've two files with data like below: file1.txt: AAA,Apples,123 BBB,Bananas,124 CCC,Carrot,125 file2.txt: Store1|AAA|123|11 Store2|BBB|124|23 Store3|CCC|125|57 Store4|DDD|126|38 So,the field separator in file1.txt is a comma and in file2.txt,it is | Now,the output should be... (2 Replies)
Discussion started by: asyed
2 Replies

5. UNIX for Advanced & Expert Users

How to find duplicates contents in a files by comparing other files?

Hi Guys , we have one directory ...in that directory all files will be set on each day.. files must have header ,contents ,footer.. i wants to compare the header,contents,footer ..if its same means display an error message as 'files contents same' (7 Replies)
Discussion started by: Venkatesh1
7 Replies

6. Shell Programming and Scripting

Comparing files in a directory against an array of files

I hope I can explain this correctly. I am using Bash-4.2 for my shell. I have a group of file names held in an array. I want to compare the names in this array against the names of files currently present in a directory. If the file does not exist in the directory, that is not a problem.... (5 Replies)
Discussion started by: BudMan
5 Replies

7. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

8. Shell Programming and Scripting

Trying to make a bash script that goes through directory files and changes things

I'm trying to write a script in a directory that goes through the column the user specifies of 4 files that are inside the directory and calculates the min and the max values. This means that if the user specifies column 5, the script will go through column 5 of all 4 files and all that should give... (2 Replies)
Discussion started by: Eric1
2 Replies

9. UNIX for Beginners Questions & Answers

Comparing two files and list the difference with common first line content of both files

I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ? Source File ************* # file: /local/test_1 # owner: own #... (4 Replies)
Discussion started by: sarathy_a35
4 Replies
k5srvutil(1M)						  System Administration Commands					     k5srvutil(1M)

NAME
k5srvutil - host key table (keytab) manipulation utility SYNOPSIS
/usr/sbin/k5srvutil operation [-ik] [-f filename] DESCRIPTION
The k5srvutil command allows a system manager to list or change keys currently in his keytab or to add new keys to the keytab. The operand operation must be one of the following: list Lists the keys in a keytab, showing version number and principal name. change Changes all the keys in the keytab to new randomly-generated keys, updating the keys in the Kerberos server's database to match those by using the kadmin protocol. If a key's version number does not match the version number stored in the Kerberos server's database, the operation fails. The old keys are retained so that existing tickets continue to work. If the -i flag is specified, k5srvutil prompts for yes or no before changing each key. If the -k option is used, the old and new keys are displayed. delold Deletes keys that are not the most recent version from the keytab. This operation should be used at some point after a change operation to remove old keys. If the -i flag is specified, k5srvutil asks the user whether the old keys associated with each principal should be removed. delete Deletes particular keys in the keytab, interactively prompting for each key. In all cases, the default keytab file is /etc/krb5.keytab file unless this is overridden by the -f option. k5srvutil uses the kadmin(1M) program to edit the keytab in place. However, old keys are retained, so they are available in case of fail- ure. OPTIONS
The following options are supported: -f filename Specify a keytab file other than the default file, /etc/krb5.keytab. -i Prompts user before changing keys when using the change or delold operands. -k Displays old and new keys when using the change operand. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWkdcu | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ SEE ALSO
ktutil(1), kadmin(1M), attributes(5) SunOS 5.11 29 Aug 2006 k5srvutil(1M)
All times are GMT -4. The time now is 04:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy