Sponsored Content
Top Forums Shell Programming and Scripting replace string in file.1 with line from file.2 Post 302315509 by devtakh on Tuesday 12th of May 2009 01:48:49 PM
Old 05-12-2009
Code:
awk 'FNR==NR{id[$1]="{"substr($0,length($1)+2,length($0))"}";next}
{a=$0;b=match($0,/\[[0-9]+\]/);
if(b>0){
c=substr($0,RSTART,RLENGTH);o=substr($0,1,b-1);print o"\\footnote"id[c]
}
else print
}' footnotes.txt ch25.txt

cheers,
Devaraj Takhellambam
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how can search a String in one text file and replace the whole line in another file

i am very new to UNIX plz help me in this scenario i have two text files as below file1.txt name=Rajakumar. Discipline=Electronics and communication. Designation=software Engineer. file2.txt name=Kannan. Discipline=Mechanical. Designation=CADD Design Engineer. ... (6 Replies)
Discussion started by: kkraja
6 Replies

2. Shell Programming and Scripting

Replace string in a file within a range of line

Hi, I want to replace the srting '; with ABCD'; in a file from line 1 to line 65. Is there any single command to do it without using awk Thanks for quick reply https://www.unix.com/images/misc/progress.gif (3 Replies)
Discussion started by: tosattam
3 Replies

3. Shell Programming and Scripting

To trim Certain field in a line of a file and replace the new string in that position

To trim 3rd field in for all the lines of a file and replace the modified string in that particular field. For example i have a file called Temp.txt having content Temp.txt ----------------- 100,234,M1234 400,234,K1734 300,345,T3456 ---------------- So the modified file output should... (4 Replies)
Discussion started by: rpadhi
4 Replies

4. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

5. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

Hi I am not the best scripter in the world and have run into a issue which you might be able to guide me on... I have two files. File1 : A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB File2: C345,... (5 Replies)
Discussion started by: luckycharm
5 Replies

6. Shell Programming and Scripting

sed or awk to replace a value in a certain line from another file containing a string

Hi experts, In my text file I have the following alot of lines like below. input.k is as follows. 2684717 -194.7050476 64.2345581 150.6500092 0 0 2684718 -213.1575623 62.7032242 150.6500092 0 0 *INCLUDE $# filename... (3 Replies)
Discussion started by: hamnsan
3 Replies

7. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies

8. Shell Programming and Scripting

Replace a string with each line from another file repeatedly

I don't know if it's been asked before but seems i gave up seeking. i have 2 files : file1.txt Monday XXXX Tuesday XXXX XXXX Wednesday Thursday XXXX XXXX is in every lines of file1.txt and i want to replace them with each line in file2.txt: home school cinema so output file is: ... (19 Replies)
Discussion started by: perseous
19 Replies

9. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

HI Can any one guide me how to achieve this task. I have 2 files env.txt #Configuration.Properties values identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register randon_password_length = 6 attachment_file_path = /pass/temp/attachments/... (1 Reply)
Discussion started by: nikilbr86
1 Replies

10. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSuUser(Contributed Perl DocPerl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr(3pm)

NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr - Use 4-argument "substr" instead of writing "substr($foo, 2, 6) = $bar". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Conway discourages the use of "substr()" as an lvalue, instead recommending that the 4-argument version of "substr()" be used instead. substr($something, 1, 2) = $newvalue; # not ok substr($something, 1, 2, $newvalue); # ok The four-argument form of "substr()" was introduced in Perl 5.005. This policy does not report violations on code which explicitly specifies an earlier version of Perl (e.g. "use 5.004;"). CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
"substr" in perlfunc (or "perldoc -f substr"). "4th argument to substr" in perl5005delta AUTHOR
Graham TerMarsch <graham@howlingfrog.com> COPYRIGHT
Copyright (c) 2005-2011 Graham TerMarsch. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-07 Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr(3pm)
All times are GMT -4. The time now is 01:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy