Sponsored Content
Full Discussion: Restricted File Comparison
Top Forums Shell Programming and Scripting Restricted File Comparison Post 302554713 by salamagd on Monday 12th of September 2011 08:32:49 PM
Old 09-12-2011
Restricted File Comparison

Hey guys,

I've got a scripting problem that has been bugging me so thought I'd ask the wise people here! Basically I have two overlapping log files, and I want to get the newest lines from the new log file that aren't in the old log file - but not the old lines in the old log that aren't in the new log.

Say the old log file has this content:
Code:
1: Apple
2: Banana
3: Carrot
4: Dog

And the new log has this content:
Code:
3: Carrot
4: Dog
5: Elephant
6: Fish

I want my script to output:
Code:
5: Elephant
6: Fish

Essentially, I want a diff of the two files, but only include the lines that are unique to the second file - is this possible?

edit: It seems that I can do it with "grep -v -x -f file1 file2", but this has O(n^2) complexity so won't work nearly fast enough with files that are reasonably long. Any other ideas?

Thanks for any help!
Giancarlo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Comparison

I have to compare two text files, very few of the lines in these files will have some difference in some column. The files size is in GB. Sample lines are as below: 11111122222222333333aaaaaaaaaabbbbbbbbbccccccccdddddd 11111122222222333333aaaaaaaaaabbbbbbbbbccccccccddeddd So assuming these... (19 Replies)
Discussion started by: net_shree
19 Replies

2. Shell Programming and Scripting

file comparison

hi I have 2 files to comapre ,in file a sible column it is numbers,in file b2 numbers and other values with coma separated. i want compare numbers in file a with file b,and the out put put should be in C with numbers in both file a and b along with other columns of file b. i used folowing... (7 Replies)
Discussion started by: satish.res
7 Replies

3. Shell Programming and Scripting

File Comparison- Need help

I have two text files which have records of thousand rows. Each row is having around 40 columns. Each column is tab delimited. Each row is delimited by newline character. My requirement is to find for each row i need to find whether any column is different between the two files. For each row i... (8 Replies)
Discussion started by: uihnybgte
8 Replies

4. Shell Programming and Scripting

File Comparison

Hi i have 2 csv files a.csv and b.csv with the same number of columns and a list of values in both of it. Each and every individual value in both the files need to compared and if it matches then print correct in a new csv file otherwise print Incorrect eg a.csv 1,12/27/2007,Reward,$10.00... (5 Replies)
Discussion started by: naveenn08
5 Replies

5. Filesystems, Disks and Memory

Restricted File Creation for particuler pattern

HI All, I have this wierd requirment. Any help will be appriciated. I need to restrict file creation with certain pattern. Suppose, i want my system not to allow creation of files with *.exe extension. The requirment is that file should not be created like it happen in windows you can't create... (0 Replies)
Discussion started by: r00t4u
0 Replies

6. Shell Programming and Scripting

two file comparison

now i have a different file zoo.txt with content 123|zoo 234|natan 456|don and file rick.txt with contents 123|dog|pie|pep 123|tail|see|newt 456|som|sin|sim 234|pay|rat|cat i want to look for lines in file zoo.txt column1 that has same corresponding lines in column 1 of... (6 Replies)
Discussion started by: dealerso
6 Replies

7. Shell Programming and Scripting

file comparison

Dear All, I would really appreciate if you can help me to resolve this file comparison I have two files: file1: chr start end ID gene_name chr1 2020 3030 1 test1 chr1 900 5000 2 test1 chr2 5000 8000 3 test2 chr3 6000 12000 4 test3 chr3 6000 15000 5 test3 file2:... (2 Replies)
Discussion started by: paolo.kunder
2 Replies

8. Shell Programming and Scripting

File Comparison: Print Lines not present in another file

Hi, I have fileA.txt like this. B01B02 D0011718 B01B03 D0012540 B01B04 D0006145 B01B05 D0004815 B01B06 D0012069 B01B07 D0004064 B01B08 D0011988 B01B09 D0012071 B01B10 D0005596 B01B11 D0011351 B01B12 D0004814 B01C01 D0011804 I want to compare this against another file (fileB.txt)... (3 Replies)
Discussion started by: genehunter
3 Replies

9. Shell Programming and Scripting

File Comparison

HI, I have two files and contains many Fields with | (pipe) delimitor, wanted to compare both the files and get only unmatched perticular fields. this i wanted to use in shell scriting. ex: first.txt 111 |abc| 230| hbc231 |bbb |210 |bbd405 |ghc |555 |cgv second.txt 111 |abc |230 |hbc231... (1 Reply)
Discussion started by: prawinmca
1 Replies

10. UNIX Desktop Questions & Answers

Restricted shell with execution permission on a file

Hi, I've created a user which shell is the restricted one (/usr/lib/rsh), but I've realized that the user cannot execute a script !!! The scope was to allow the ssh access to a user that could not access to any other directories but there that user should be able to run a script that retrieves ... (2 Replies)
Discussion started by: mary0
2 Replies
sam(1M) 																   sam(1M)

NAME
sam - HP System Administration Manager (HP SAM) SYNOPSIS
[ login | ] DESCRIPTION
The command launches the HP System Management Homepage (HP SMH) program for performing system administration on the HP-UX operating system. HP SMH is an enhanced web-based program of HP System Administration Manager (HP SAM) in the HP-UX 11i V3 release. For more information, see smh(1M). If the environment variable is set, the Web-based HP SMH is displayed. If the environment variable is not set, the terminal user interface of HP SMH is displayed. Deprecation Notice The command is deprecated in HP-UX 11i V3 release. HP recommends you use the command. Options recognizes the following options. Execute SAM with the privileges associated with the specified login. When used in conjunction with the Restricted SMH Builder is invoked and initialized with the privileges associated with the specified login. You must be a superuser to use this option. See below for more information. Invokes Restricted SMH. This enables the system administrator to assign limited privileged user access to SMH functionality. You must be a privi- leged user to use this option. See the section below for more information. Restricted SMH Generally, SMH requires privileged user rights to execute successfully. However, through the use of Restricted SMH, SMH can be configured to allow subsets of its functionality to certain non-privileged users or groups of users. System administrators access Restricted SMH by invoking SMH with the option (see above). In Restricted SMH, system administrators may assign subsets of SAM functionality on a per-user or per-group basis. When Restricted SMH is used, non-privileged users are promoted to privileged users when necessary to enable them to execute successfully. By default, Restricted SMH executes all applications as privileged user. However, certain applications, like software distributor have their own security mechanism and do not follow the Restricted SMH security model. In such cases, the application launched through Restricted SMH will be executed with the login ID of the user who invokes it. A non-privileged user who has been given Restricted SMH privileges simply executes and sees only those areas the user is privileged to access. All the SMH functional areas require the user to be promoted to be a privileged user in order to execute successfully. SMH does this auto- matically as needed. SMH provides a default set of SMH functional areas that the system administrator can assign to other users. Restricted SMH applies only to terminal user interfaces. Restricted SMH does not apply to Web-based GUI (HP SMH) since HP SMH has its own roles. For more information, refer to the HP SMH documentation available at and the HP SMH product online help system. SAM Functional Areas SAM has been replaced by SMH. For more information on the various functional areas, see smh(1M). SAM Logging All actions taken by SAM are logged into the SAM log file at The log entries in this file can be viewed using the SAM utility command (see samlog_viewer(1)). can filter the log file by user name, by time of log entry creation, and by level of detail. Functionality Obsolescence and Changes The following functional areas of the previous SAM interface have been removed, changed, or are planned to be obsolete in a future release of HP-UX. Alternate procedures are listed as appropriate. o Trusted systems is planned for obsolescence post HP-UX 11i V3 release. o Backup and Recovery. Use the and commands from the HP-UX system prompt. You can also use backup tools, such as pax(1), from the HP-UX command prompt. o Tape Drives. Add or remove device entries by editing the file or use and commands from the HP-UX command prompt. o Terminals and Modems. Use and commands from the HP-UX command prompt. o Uninterruptable Power Supplies. o Performance Management. Monitor the performance of HP-UX using the commands and o Process Management. To manage processes for such functions as stopping, continuing, changing priority, use and o Routine Tasks. Tasks such as shutting down the system and removing files that are large, unowned, or core files are handled by and o Run SAM on Remote Systems. Executing or configuring SAM on remote systems is no longer needed, because all systems are managed through HP Systems Insight Manager (HP SIM). For more information on HP SIM, see o Custom applications cannot be added using SAM. Any custom application that needs to be added in SAM must provide its own registration files. The registration file has a specific format. You can view a sample registration file from WARNINGS
cannot be run in the background even if the environment variable is set from HP-UX 11i V3 release. The Disks and File Systems area of SAM does not display or configure all the types of devices when the legacy mode of mass storage stack is disabled. AUTHOR
was developed by HP. SEE ALSO
samlog_viewer(1), evweb(1M), fsweb(1M), hpsmh(1M), kcweb(1M), ncweb(1M), parmgr(1M), pdweb(1M), secweb(1M), smh(1M), smhstartconfig(1M), ugweb(1M), intro(7). at TO BE OBSOLETED sam(1M)
All times are GMT -4. The time now is 11:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy