Replace sting in FILE1.txt with FILE2.txt. FILE1.txt record must have at least one state is repeated once.But need to replace only from second occurrence in record in FILE1.txt
Condition: order of searching the records in FILE2.txt is impartent.
So when the FILE2.txt record entry is matched with FILE1.txt then break the loop and don't search again the FILE2.txt next record. see below exampe.
FILE1.txt
----------
FILE2.txt
------------
output:
-------
(TEXAS is matched so replaced TEXAS with TX in 2nd occurrence)
(DALLAS and CALIFORNIA is matched more than once but as the order in FILE2.txt is impartent so DALLAS is coming first than CALIFORNIA so replacing DALLS only and breaking the loop and not searching again for CALIFORNIA)
I have implemented this using while loop and its working as expected but as the FILE1.txt have Millions of records and FILE2.txt have 50 records, so its taking Hours to complete. Any AWK solution for this to speed up the performance please ?
Last edited by Don Cragun; 08-30-2014 at 04:06 AM..
Reason: Remove QUOTE tags; add CODE tags.
Hi, everybody.
I just wonder whether there are a couple of free Linux servers running as terminals where people can practice Unix Shell Programming?
I'd like to set up one myself but unfortunatly can't do it. I can't switch to Linux now coz I run a couple of servers on my machine.
Cygwin is... (3 Replies)
About 4 years ago I wrote this tool inspired by Rob Urban's collect tool for DEC's Tru64 Unix. What makes this tool as different as collect was in its day is its ability to run at a low overhead and collect tons of stuff. I've expanded the general concept and even include data not available in... (0 Replies)
I am doing the following script in k shell
sed -i 's/FILENAME/$i/g' TEST/test$j.ctl > TEST/control$j.ctl
In the file it replaces $i for all FILENAME, it doesnot replace with the value of i. I put single quotes like below
sed -i 's/FILENAME/'$i'/g' TEST/test$j.ctl > TEST/control$j.ctl
I... (9 Replies)
We develop software for diagnostic tools for cars. we a use a portable PC(x86) runs Win98 to run our applications.
Hence the working environment in the company is Windows, specifically we use BASIC to develop the GUI, communication functions, DLL, etc. and run them on the Win98 PC.
We suggested... (1 Reply)
Hello All,
Request any one of Unix/Linux masters to clarify on the below.
How far it is feasible to open a new ftp connection for transferring each file when there are multiple files to be sent. I have developed shell script to send all files at single stretch but some how it doesnt suit to... (3 Replies)
One of our database server is suddenly became very slow and i have no clue what to do .Please help. I m sharing the performance inforamtion regarding cpu,harddisk,ram .
########CPU Information########
Machine Uptime Information:
uptime
10:25:06 up 16:50, 1 user, load average: 5.84, 5.65,... (10 Replies)
Hi,
I have been working on Sun Solaris since a long time. Recently I got to work on RH Linux. My Linux version details are:
Linux 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
I have a simple command in my shell script:
export BKPTAG=`date... (3 Replies)
IN solaris, for network high-availability we are using IPMP concept, can u tell me in REDHAT LINUX what we are using... also pls share good step to read & understand the that concept...
Also performance issue in linux what are step & cmd can u tell me??? (2 Replies)
Hi All,
I am facing performance issue while rinning the LINUX shell script.
I have file1 and file 2. File one is the source file and file 2 is lookup file. Need to replace if the pattern is matching in file1 with file2.
The order of lookup file is important as if any match then exit... (8 Replies)
Hi,
I am beginner in shell scripting. I have written a script to parse file(s) having large number of lines each having multiple comma separated strings.
But it seems like script is very slow. It took more than 30mins to parse a file with size 120MB (523564 lines), below is the script code
... (4 Replies)
Discussion started by: imrandec85
4 Replies
LEARN ABOUT DEBIAN
comm
COMM(1) User Commands COMM(1)NAME
comm - compare two sorted files line by line
SYNOPSIS
comm [OPTION]... FILE1 FILE2
DESCRIPTION
Compare sorted files FILE1 and FILE2 line by line.
With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and
column three contains lines common to both files.
-1 suppress column 1 (lines unique to FILE1)
-2 suppress column 2 (lines unique to FILE2)
-3 suppress column 3 (lines that appear in both files)
--check-order
check that the input is correctly sorted, even if all input lines are pairable
--nocheck-order
do not check that the input is correctly sorted
--output-delimiter=STR
separate columns with STR
--help display this help and exit
--version
output version information and exit
Note, comparisons honor the rules specified by `LC_COLLATE'.
EXAMPLES
comm -12 file1 file2
Print only lines present in both file1 and file2.
comm -3 file1 file2
Print lines in file1 not in file2, and vice versa.
AUTHOR
Written by Richard M. Stallman and David MacKenzie.
REPORTING BUGS
Report comm bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report comm translation bugs to <http://translationproject.org/team/>
COPYRIGHT
Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO join(1), uniq(1)
The full documentation for comm is maintained as a Texinfo manual. If the info and comm programs are properly installed at your site, the
command
info coreutils 'comm invocation'
should give you access to the complete manual.
GNU coreutils 8.12.197-032bb September 2011 COMM(1)