Sponsored Content
Top Forums Shell Programming and Scripting replace string in file.1 with line from file.2 Post 302315169 by durden_tyler on Monday 11th of May 2009 06:38:20 PM
Old 05-11-2009
Code:
$
$ cat ch25.txt
First there was nothing. Then there was Calvin[1].
blah blah blah
blah blah blah
"On a long enough timeline, the survival rate for everyone drops to zero" [2].
blah blah blah
"Dr. Livingstone, I presume?" [3]
blah blah blah
$
$ cat footnotes.txt
[1] A memorable quote from Bill Waterson's Calvin and Hobbes.
[2] Spoken by Tyler Durden, in Chuck Palahniuk's "Fight Club".
[3] By Henry Morton Stanley, on meeting Dr. David Livingstone near Lake Tanganyika on Nov. 10th, 1871.
$
$
$ perl -ne 'BEGIN {
>   open(FN,"footnotes.txt");
>   while(<FN>) {chomp; $fnote{$1}=$2 if (/(\[\d+\]) (.*)/)}
>   close(FN)}
> chomp;
> if (/(.*?)(\[\d+\])/) {print "$1\\footnote{$fnote{$2}}\n"}
> else {print $_,"\n"}' ch25.txt
First there was nothing. Then there was Calvin\footnote{A memorable quote from Bill Waterson's Calvin and Hobbes.}
blah blah blah
blah blah blah
"On a long enough timeline, the survival rate for everyone drops to zero" \footnote{Spoken by Tyler Durden, in Chuck Palahniuk's "FightClub".}
blah blah blah
"Dr. Livingstone, I presume?" \footnote{By Henry Morton Stanley, on meeting Dr. David Livingstone near Lake Tanganyika on Nov. 10th, 1871.}
blah blah blah
$
$

HTH,
tyler_durden

___________________________________________________________
"It's only after we've lost everything that we're free to do anything."
 

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
radiusd.conf(5) 					   FreeRADIUS configuration file					   radiusd.conf(5)

NAME
radiusd.conf - configuration file for the FreeRADIUS server DESCRIPTION
The radiusd.conf file resides in the radius database directory, by default /etc/raddb. It defines the global configuration for the FreeRA- DIUS RADIUS server. CONTENTS
There are a large number of configuration parameters for the server. Most are documented in the file itself as comments. This page docu- ments only the format of the file. Please read the radiusd.conf file itself for more information. The configuration file parser is independent of the server configuration. This means that you can put almost anything into the configura- tion file. So long as it is properly formatted, the server will start. When the server parses the configuration file, it looks only for those configurations it understands. Extra configuration items are ignored. This "feature" can be (ab)used in certain interesting ways. FILE FORMAT
The file format is line-based, like many other Unix configuration files. Each entry in the file must be placed on a line by itself, although continuations are supported. The file consists of configuration items (variable = value pairs), sections, and comments. Variables Variables can be set via: name = value Single and double-quoted strings are permitted: string1 = "hello world" string2 = 'hello mom' Sections A section begins with a section name, followed on the same line by an open bracket '{'. Section may contain other sections, com- ments, or variables. Sections may be nested to any depth, limited only by available memory. A section ends with a close bracket '}', on a line by itself. section { ... } Sections can sometimes have a second name following the first one. The situations where this is legal depend on the context. See the examples and comments in the radiusd.conf file for more information. section foo { ... } Comments Any line beginning with a (#) is deemed to be a comment, and is ignored. Comments can appear after a variable or section defini- tions. # comment foo = bar # set variable 'foo' to value 'bar' section { # start of section ... } # end of section Continuations Long lines can be broken up via continuations, using '' as the last character of the line. For example, the following entry: foo = "blah blah blah" will set the value of the variable "foo" to "blah blah blah". Any CR or LF is not turned into a space, but all other whitespace is preserved in the final value. REFERENCES
The value of a variable can reference another variable. These references are evaluated when the configuration file is loaded, which means that there is no run-time cost associated with them. This feature is most useful for turning long, repeated pieces of text into short ones. Variables are referenced by ${variable_name}, as in the following examples. foo = bar # set variable 'foo' to value 'bar' who = ${foo} # sets variable 'who' to value of variable 'foo' my = "${foo} a" # sets variable 'my' to "bar a" If the variable exists in a section or subsection, it can be referenced as ${section.subsection.variable}. Forward references are not allowed. Relative references are allowed, by pre-pending the name with one or more period. blogs = ${.foo} Will set variable blogs to the value of variable foo, from the current section. blogs = ${..foo} Will set variable blogs to the value of variable foo, from the section which contains the current section. blogs = ${modules.detail.detailfile} Will set variable blogs to the value of variable detailfile, of the detail module, which is in the modules section of the configuration file. FILES
/etc/raddb/radiusd.conf SEE ALSO
radiusd(8) unlang(5) AUTHOR
Alan DeKok <aland@freeradius.org> 12 Jun 2007 radiusd.conf(5)
All times are GMT -4. The time now is 08:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy