Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk to update file with partial matching line in another file and append text Post 303034019 by cmccabe on Tuesday 16th of April 2019 05:47:37 PM
Old 04-16-2019
I made an typo in f2
Should just be one column of multiple strings.
Code:
/path/to/the/xxx/data/0000-yyyy_v1_0000-yyyy_RNA_v1/190326-Control_v1_20190328071906449 
/path/to/the/xxx/data/00-0000_xxxx-03_v1/00-0000_xxxx-03_v1_20190322115521953
/path/to/the/xxx/data/1111-xxxx-03_v1/1111-xxxx-03_v1_20190322115521953

So I thought i adjusted the script below correctly to capture the partial match. That is the $2 will be in that long string. Thank you Smilie.

Awk
Code:
awk 'NR==FNR {for(i=1; i<=NF; i++) id[$i]=$1; next} $2 in id{$3=id/[$2]/ "/test/id/" $1 "_raw.file_fixed.txt"}1' f2 f1
awk 'NR==FNR {for(i=1; i<=NF; i++) id[$i]=$1; next} $2 in id{$3=id/[$i]/ "/test/id/" $1 "_raw.file_fixed.txt"}1' f2 f1


Last edited by cmccabe; 04-17-2019 at 12:23 PM.. Reason: fixed format, updated awk
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

2. Shell Programming and Scripting

How to append text to the second line of a file

Say I have a text file like: 1 3 4 How would I use ksh to put the number '2' into the second line of that file? I'm using OpenBSD so the sed syntax might be a bit different (I have no idea how to use sed, though) (4 Replies)
Discussion started by: guitarscn
4 Replies

3. Shell Programming and Scripting

append delimeter count for each line in text file

Hi guys, plz tell me how to achieve this how to delete the lines in a file using sed command (6 Replies)
Discussion started by: hari908
6 Replies

4. Shell Programming and Scripting

AWK - Print partial line/partial field

Hello, this is probably a simple request but I've been toying with it for a while. I have a large list of devices and commands that were run with a script, now I have lines such as: a-router-hostname-C#show ver I want to print everything up to (and excluding) the # and everything after it... (3 Replies)
Discussion started by: ippy98
3 Replies

5. UNIX for Dummies Questions & Answers

Append a line to single column text file

I would like to add a line to the end of a single column text file. How do I go about doing that? Input: BEGIN 1 2 3 Output: BEGIN 1 2 3 END Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

Update specific field in a line of text file

I have a text file like this: subject1:LecturerA:10 subject2:LecturerA:40 if I was given string in column 1 and 2 (which are subject 1 and LecturerA) , i need to update 3rd field of that line containing that given string , which is, number 10 need to be updated to 100 ,for example. The... (6 Replies)
Discussion started by: bmtoan
6 Replies

7. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. Shell Programming and Scripting

Append Text File from another File in line 6

Hi, Anyone can help on how to append a file1.txt into file2.txt after line 3 using sed command. file1.txt 1. testa 2. testb 3. testc 4. testd 5. test5 6. test6 file2.txt break here this is a test break end here output 1. testa 2. testb (1 Reply)
Discussion started by: fspalero
1 Replies

9. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

awk to update file with sum of matching fields in another file

In the awk below I am trying to add a penalty to a score to each matching $1 in file2 based on the sum of $3+$4 (variable TL) from file1. Then the $4 value in file1 is divided by TL and multiplied by 100 (this valvue is variable S). Finally, $2 in file2 - S gives the updated $2 result in file2.... (2 Replies)
Discussion started by: cmccabe
2 Replies
CheckDigits::M10_001(3pm)				User Contributed Perl Documentation				 CheckDigits::M10_001(3pm)

NAME
CheckDigits::M10_001 - compute check digits for Bahncard (DE), IMEI, IMEISV, ISIN, Miles&More, Payback (DE), Personnummer (SE), Passport (BR), Credit Cards, SSN (US), Samordningsnummer (SE), VAT RN (ES), VAT RN (IT), VAT RN (SE), International Securities Identifikation Number (ISIN) SYNOPSIS
use Algorithm::CheckDigits; $visa = CheckDigits('visa'); if ($visa->is_valid('4111 1111 1111 1111')) { # do something } $cn = $visa->complete('4111 1111 1111 111'); # $cn = '4111 1111 1111 1111' $cd = $visa->checkdigit('4111 1111 1111 1111'); # $cd = '7' $bn = $visa->basenumber('4111 1111 1111 1111'); # $bn = '4111 1111 1111 111' DESCRIPTION
ALGORITHM 1. Beginning right all numbers are weighted alternatively 1 and 2 (that is the check digit is weighted 1). 2. The total of the digits of all products is computed. 3. The sum of step 3 ist taken modulo 10. 4. The check digit is the difference between 10 and the number from step 3. To validate the total of the digits of all numbers inclusive check digit taken modulo 10 must be 0. METHODS is_valid($number) Returns true only if $number consists solely of numbers and the last digit is a valid check digit according to the algorithm given above. Returns false otherwise, complete($number) The check digit for $number is computed and concatenated to the end of $number. Returns the complete number with check digit or '' if $number does not consist solely of digits and spaces. basenumber($number) Returns the basenumber of $number if $number has a valid check digit. Return '' otherwise. checkdigit($number) Returns the checkdigit of $number if $number has a valid check digit. Return '' otherwise. EXPORT None by default. AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de> SEE ALSO
perl, CheckDigits, www.pruefziffernberechnung.de. For IMEI, IMEISV: ETSI Technical Specification TS 100 508 (v6.2.0) perl v5.10.0 2008-05-17 CheckDigits::M10_001(3pm)
All times are GMT -4. The time now is 02:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy