Sponsored Content
Top Forums Shell Programming and Scripting Shell Script to Create non-duplicate lists from two lists Post 302410381 by mlv_99 on Monday 5th of April 2010 09:05:26 PM
Old 04-05-2010
Shell Script: Compare 2 Files and Extract Unique Elements of Each File into 2 New Files

Thanks for the reply danmero. I made a mistake in the description. Let me re-phrase the question again.


File_A contains Strings and content's elements are NOT IN ANY ORDER OR PATTERN AND file varies in size from one run to the next run:
a <- in both File_A and File_B
b <- unique to File_A
c <- in both File_A and File_B
d <- unique to File_A

File_B contains Strings and content's elements are NOT IN ANY ORDER OR PATTERN AND file varies in size from one run to the next run:
a <- in both File_A and File_B
c <- in both File_A and File_B
z <- unique to File_B



Need to have script written in either sh or ksh. Resultant files (File_New_A and File_New_B) is derived from comparing contents of files File_A and File_B where resultant string elements in File_New_A and File_New_B are listed below. Resultant File_New_A will contain only unique elements found only in File_A when compared with File_B. File_New_B will contain only unique elements found in only File_B when compared with File_A.


Resultant files:
File_New_A contains String:
b <- unique to File_A
d <- unique to File_A


File_New_B contains String:
z <- unique to File_B


++++++++++++++++++++++++++++++++++++++

The next run could have

File_A contains Strings and content's elements are NOT IN ANY ORDER OR PATTERN AND file varies in size from one run to the next run:
m <- only in File_A
n <- only in File_A
o <- only in File_A
p <- only in File_A
q <- in both File_A and File_B
r <- in both File_A and File_B

File_B contains Strings and content's elements are NOT IN ANY ORDER OR PATTERN AND file varies in size from one run to the next run:
q <- in both File_A and File_B
r <- in both File_A and File_B

Resultant files after comparing File_A and File_B:

Resultant files:
File_New_A contains String:
m <- unique to File_A
n <- unique to File_A
o <- unique to File_A
p <- unique to File_A

File_New_B contains String:

No elements in File_New_B since File_B have no unique elements to File_B, all files in File_B are also in File_A; therefore File_New_B is empty.

I hope this is more clearer.

Thank you.

Matt
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check lists for Unix Shell Programming

Hi all, Can anyone provide me any checklists or a list of steps I should follow before executing my scripts. Could also tell me if there are any other standards to be followed while shell programming like naming conventions for variables etc. Your help would be much appreciated. Regards,... (2 Replies)
Discussion started by: srikanth_ksv
2 Replies

2. Shell Programming and Scripting

Help with a shell script to concatenate lists together

Below is a description of what im trying to achieve: Write a shell script to concatenate lists together, and output the resulting list. Do not include any argument that is a sub-list of the entire list. (The script will clean the list of any redundant items.) You must preserve the original order... (1 Reply)
Discussion started by: rfourn
1 Replies

3. Shell Programming and Scripting

Editing lists of integers in 1d files with bash shell

Hi, I need a script that will: 1. Go through about 20 different folders, each containing about 20 1d files. The 1d files go something like this: 22.253 37.707 78.117 112.374 127.944 156.067 180.956 233.785 249.256 ... (1 Reply)
Discussion started by: ac130pilot
1 Replies

4. Shell Programming and Scripting

C shell: Working with lists

Hello Unix Gurus, I have: A list of parameters that repeat (in .txt file) Example: params.txt Series: XYZ Manufacturer: ... Software Version: ... Year made: ... Series Series: XYZ Manufacturer: ... Software Version: ... Year made: ... Series Series: ABC Manufacturer: ... ... (7 Replies)
Discussion started by: lapiduslost
7 Replies

5. Shell Programming and Scripting

Bash script to compare two lists

Hi, I do little bash scripting so sorry for my ignorance. How do I compare if the two variable not match and if they do not match run a command. I was thinking a for loop but then I need another for loop for the 2nd list and I do not think that would work as in the real world there could... (2 Replies)
Discussion started by: GermanJulian
2 Replies

6. Shell Programming and Scripting

Shell script that lists files with different owner than the folder

Hello, I'm trying to write a script which is listing files based on different preferences, like filetype or permissions. All is fine, except for one: I want to list files in /home which has a different owner than the home directory it is in. Here is an example: /home/UserA is the directory, and... (10 Replies)
Discussion started by: Zwiebi
10 Replies

7. Shell Programming and Scripting

get the lists

I expert, I may cross post something similar but I dirtyed my quesion somehow to be clear in the thread #cat file1 88dee gcc: Grok for callconvention-hard to enable hard float a2ad2 eglibc: package mtrace separately 61487 python: bump PR of packages after update of distutils.bbclass... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

8. Shell Programming and Scripting

Removing duplicate entries from edge-lists

I have a file which has connections given as: A B 0.1 B C 5.8 C B 5.8 E F 0.67 B A 0.1 A B and B A are same, so I want to remove one of them. Same with BC and CB. Desired output: A B 0.1 B C 5.8 E F 0.67 (2 Replies)
Discussion started by: Sanchari
2 Replies

9. Shell Programming and Scripting

• Write a shell script that upon invocation shows the time and date and lists all the logged-in user

help me (1 Reply)
Discussion started by: sonu pandey
1 Replies

10. UNIX for Beginners Questions & Answers

How to get script to create a new file that lists folder content sorted by size?

I have a script that sorts and processes unsorted files to newly created directories. Its working great, but I am trying to understand the leanest method to get the script to create an additional file within each newly created directory that: Contains a list of all files in the directory... (4 Replies)
Discussion started by: Braveheart
4 Replies
ifup(8) 																   ifup(8)

NAME
ifup - bring a network interface up ifdown - take a network interface down SYNOPSIS
ifup [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE] [--allow CLASS] -a|IFACE... ifup -h|--help ifup -V|--version ifdown [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE] [--allow CLASS] -a|IFACE... DESCRIPTION
The ifup and ifdown commands may be used to configure (or, respectively, deconfigure) network interfaces based on interface definitions in the file /etc/network/interfaces. OPTIONS
A summary of options is included below. -a, --all If given to ifup, affect all interfaces marked auto. Interfaces are brought up in the order in which they are defined in /etc/net- work/interfaces. If given to ifdown, affect all defined interfaces. Interfaces are brought down in the order in which they are currently listed in the state file. Only interfaces defined in /etc/network/interfaces will be brought down. --force Force configuration or deconfiguration of the interface. -h, --help Show summary of options. --allow=CLASS Only allow interfaces listed in an allow-CLASS line in /etc/network/interfaces to be acted upon. -i FILE, --interfaces=FILE Read interface definitions from FILE instead of from /etc/network/interfaces. -e PATTERN, --exclude=PATTERN Exclude interfaces from the list of interfaces to operate on by the PATTERN. Notice that the PATTERN can be a full interface name or substrings that match interfaces. Users could easily have unexpected behaviour if they use a small string to do the match. -n, --no-act Don't configure any interfaces or run any "up" or "down" commands. --no-mappings Don't run any mappings. See interfaces(5) for more information about the mapping feature. -V, --version Show copyright and version information. -v, --verbose Show commands as they are executed. EXAMPLES
ifup -a Bring up all the interfaces defined with auto in /etc/network/interfaces ifup eth0 Bring up interface eth0 ifup eth0=home Bring up interface eth0 as logical interface home ifdown -a Bring down all interfaces that are currently up. NOTES
ifup and ifdown are actually the same program called by different names. The program does not configure network interfaces directly; it runs low level utilities such as ip to do its dirty work. FILES
/etc/network/interfaces definitions of network interfaces See interfaces(5) for more information. /var/run/network/ifstate current state of network interfaces KNOWN BUGS
/LIMITATIONS The program keeps records of whether network interfaces are up or down. Under exceptional circumstances these records can become inconsis- tent with the real states of the interfaces. For example, an interface that was brought up using ifup and later deconfigured using ifcon- fig will still be recorded as up. To fix this you can use the --force option to force ifup or ifdown to run configuration or deconfigura- tion commands despite what it considers the current state of the interface to be. The file /var/run/network/ifstate must be writable for ifup or ifdown to work properly. On Ubuntu the /var/run location is a temporary filesystem which is always writable and thrown away on shutdown. You can also use the --force option to run configuration or deconfigura- tion commands without updating the file. Note that the program does not run automatically: ifup alone does not bring up interfaces that appear as a result of hardware being installed and ifdown alone does not bring down interfaces that disappear as a result of hardware being removed. To automate the configura- tion of network interfaces you need to install other packages such as hotplug(8) or ifplugd(8). AUTHOR
The ifupdown suite was written by Anthony Towns <aj@azure.humbug.org.au>. SEE ALSO
interfaces(5), ip(8), ifconfig(8). IFUPDOWN
22 May 2004 ifup(8)
All times are GMT -4. The time now is 06:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy