04-10-2020
When working on the first input (file2), NR == FNR, it collects field 2's values into an array indexed by field 1.
When working on the second, it checks if field 3 begins with sign, and replaces this with the respective array value (agin indexed by field 1).
The final 1 represents a "TRUE" result and starts the default action which is print which by default prints $0.
This User Gave Thanks to RudiC For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi.
If we have this file
A B C
7 8 9
1 2 10
and this other file
A C D F
7 9 2 3
9 2 3 4
The result i´m looking for is intersection with A B C D F
so the answer here will be (10 Replies)
Discussion started by: alcalina
10 Replies
2. Ubuntu
Dear All,
I am new to this forum and please ignore my little knowledge :p
I have two types of data (a subset is given below)
data version 1:
439798 2 1
451209 1 2
508696 2 1
555760 2 1
582757 1 2
582889 1 2
691827... (2 Replies)
Discussion started by: evoll
2 Replies
3. Shell Programming and Scripting
Hi,
I am writing a comparator script, which comapre two txt files(column by column)
below are the precondition of this comparator
1)columns of file are not seperated
Ex.
file1.txt
8888812341181892
1243548895685687
8945896789897789
1111111111111111
file2.txt
9578956789567897... (2 Replies)
Discussion started by: kumar96877
2 Replies
4. Shell Programming and Scripting
hi Friends
need to compare columns in one file where the data looks like below
laptop,IBM
phone,samsung
car,rental
user1,laptop
user2,laptop
user3,phone
want to get output as
laptop,IBM
phone,samsung
car,rental
user1,IBM
user2,IBM
user3,samsung
need to seach $2 in array of $1 and... (4 Replies)
Discussion started by: arun1401
4 Replies
5. Shell Programming and Scripting
Hello everyone,
I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble.
I have many files each having two columns and hundreds of rows.
first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies
6. Shell Programming and Scripting
Hi All,
I have 2 files in the following format :
File 1
S00999999|BHANU|TEST|007 JOHN DOE APT 999||VENGA HIGHWAY|MA|09566|SCO DUAL|20140201|20140331|20140401|20140630|20140327|
S00888888|BU|TES|009 JOHN DOE APT 909||SENGA HIGHWAY|MA|08566|SCO... (1 Reply)
Discussion started by: nua7
1 Replies
7. Shell Programming and Scripting
Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns.
I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies
8. Shell Programming and Scripting
Hi,
I am new to Unix and I am finding it hard to fix a particular logic.
The context is as below.
File 1 :
This contains of 5 fields :
Type | Bank Code | Account | Name | Date/Time
60|ABC123|TX123456|XXXX|YYYYMMDDHH:MM:SS
72|ABC123|MYD34561|XXXX|YYYYMMDDHH:MM:SS... (4 Replies)
Discussion started by: DJose
4 Replies
9. Shell Programming and Scripting
Hello,
I have two text tab delimited files
File 1 has 30 columns. I am pasting only first 9
Chr Position Ref Alt Score Gene HGVS_C HGVS_P Coding_Consequence dbSNP
1 17312743 C T 1 Gene1 - ... (2 Replies)
Discussion started by: nans
2 Replies
10. Shell Programming and Scripting
Example:
I have files in below format
file 1:
zxc,133,joe@example.com
cst,222,xyz@example1.com
File 2 Contains:
hxd
hcd
jws
zxc
cst
File 1 has 50000 lines and file 2 has around 30000 lines :
Expected Output has to be :
hxd
hcd
jws (5 Replies)
Discussion started by: TestPractice
5 Replies
LEARN ABOUT MOJAVE
replace
REPLACE(1) MySQL Database System REPLACE(1)
NAME
replace - a string-replacement utility
SYNOPSIS
replace arguments
DESCRIPTION
The replace utility program changes strings in place in files or on the standard input.
Note
The replace utility is deprecated as of MySQL 5.7.18 and is removed in MySQL 8.0.
Invoke replace in one of the following ways:
shell> replace from to [from to] ... -- file_name [file_name] ...
shell> replace from to [from to] ... < file_name
from represents a string to look for and to represents its replacement. There can be one or more pairs of strings.
Use the -- option to indicate where the string-replacement list ends and the file names begin. In this case, any file named on the command
line is modified in place, so you may want to make a copy of the original before converting it. replace prints a message indicating which
of the input files it actually modifies.
If the -- option is not given, replace reads the standard input and writes to the standard output.
replace uses a finite state machine to match longer strings first. It can be used to swap strings. For example, the following command swaps
a and b in the given files, file1 and file2:
shell> replace a b b a -- file1 file2 ...
replace supports the following options.
o -?, -I
Display a help message and exit.
o -#debug_options
Enable debugging.
o -s
Silent mode. Print less information what the program does.
o -v
Verbose mode. Print more information about what the program does.
o -V
Display version information and exit.
COPYRIGHT
Copyright (C) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the License.
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online
at http://dev.mysql.com/doc/.
AUTHOR
Oracle Corporation (http://dev.mysql.com/).
MySQL 5.7 06/07/2018 REPLACE(1)