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
XmFrame(3X)															       XmFrame(3X)

NAME
XmFrame - The Frame widget class SYNOPSIS
#include <Xm/Frame.h> DESCRIPTION
Frame is a very simple manager used to enclose a single work area child in a border drawn by Frame. It uses the Manager class resources for border drawing and performs geometry management so that its size always matches its child's outer size plus the Frame's margins and shadow thickness. Frame is most often used to enclose other managers when the application developer desires the manager to have the same border appearance as the primitive widgets. Frame can also be used to enclose primitive widgets that do not support the same type of border drawing. This gives visual consistency when you develop applications using diverse widget sets. Constraint resources are used to designate a child as the Frame title, align its text, and control its vertical alignment in relation to Frame's top shadow. The title appears only at the top of the Frame. If the Frame's parent is a Shell widget, XmNshadowType defaults to XmSHADOW_OUT, and Manager's resource XmNshadowThickness defaults to 1. If the Frame's parent is not a Shell widget, XmNshadowType defaults to XmSHADOW_ETCHED_IN, and Manager's resource XmNshadowThickness defaults to 2. Classes Frame inherits behavior and resources from the Core, Composite, Constraint, and XmManager classes. The class pointer is xmFrameWidgetClass. The class name is XmFrame. New Resources The following table defines a set of widget resources used by the programmer to specify data. The programmer can also set the resource values for the inherited classes to set attributes for this widget. To reference a resource by name or by class in a .Xdefaults file, remove the XmN or XmC prefix and use the remaining letters. To specify one of the defined values for a resource in a .Xdefaults file, remove the Xm prefix and use the remaining letters (in either lowercase or uppercase, but include any underscores between words). The codes in the access column indicate if the given resource can be set at creation time (C), set by using XtSetValues (S), retrieved by using XtGetValues (G), or is not applicable (N/A). XmFrame Resource Set Class: XmCMarginWidth Default: 0 Type: Dimension Access: CSG Class: XmCMarginHeight Default: 0 Type: Dimension Access: CSG Class: XmC- ShadowType Default: dynamic Type: unsigned char Access: CSG Specifies the padding space on the left and right sides between Frame's child and Frame's shadow drawing. Specifies the padding space on the top and bottom sides between Frame's child and Frame's shadow drawing. When a title is present, the top margin equals the value specified by this resource plus the distance (if any) that the title extends below the top shadow. Describes the drawing style for Frame. This resource can have the following values: XmSHADOW_IN--draws Frame so that it appears inset. This means that the bottom shadow visuals and top shadow visuals are reversed. XmSHADOW_OUT--draws Frame so that it appears outset. This is the default if Frame's parent is a Shell widget. XmSHADOW_ETCHED_IN--draws Frame using a double line giving the effect of a line etched into the window. The thickness of the double line is equal to the value of XmNshadowThickness. This is the default when Frame's parent is not a Shell widget. XmSHADOW_ETCHED_OUT--draws Frame using a double line giving the effect of a line coming out of the window. The thickness of the double line is equal to the value of XmNshadowThickness. XmFrame Constraint Resource Set Class: XmCChildType Default: XmFRAME_WORKAREA_CHILD Type: unsigned char Access: CSG Class: XmCChildHorizontalAlignment Default: XmALIGN- MENT_BEGINNING Type: unsigned char Access: CSG Class: XmCChildHorizontalSpacing Default: dynamic Type: Dimension Access: CSG Class: XmC- ChildVerticalAlignment Default: XmALIGNMENT_CENTER Type: unsigned char Access: CSG Specifies whether a child is a title or work area. Frame supports a single title and/or work area child. The possible values are: XmFRAME_TITLE_CHILD XmFRAME_WORKAREA_CHILD XmFRAME_GENERIC_CHILD The Frame geometry manager ignores any child of type XmFRAME_GENERIC_CHILD. Specifies the alignment of the title. This resource has the following values: XmALIGNMENT_BEGINNING XmALIGNMENT_CENTER XmALIGNMENT_END See the description of XmNalignment in the XmLabel(3X) man page for an explanation of these values. Specifies the minimum distance between either edge of the title text and the inner edge of the Frame shadow. Clipping of the title text occurs in order to main- tain this spacing. The default value is the margin width of the Frame. Specifies the vertical alignment of the title text, or the title area in relation to the top shadow of the Frame. XmALIGNMENT_BASELINE_BOTTOM--causes the baseline of the title to align ver- tically with the top shadow of the Frame. In the case of a multi-line title, the baseline of the last line of text aligns verti- cally with the top shadow of the Frame. XmALIGNMENT_BASELINE_TOP--causes the baseline of the first line of the title to align ver- tically with the top shadow of the Frame. XmALIGNMENT_WIDGET_TOP--causes the top edge of the title area to align vertically with the top shadow of the Frame. XmALIGNMENT_CENTER--causes the center of the title area to align vertically with the top shadow of the Frame. XmALIGNMENT_WIDGET_BOTTOM--causes the bottom edge of the title area to align vertically with the top shadow of the Frame. Inherited Resources Frame inherits behavior and resources from the following superclasses. For a complete description of each resource, refer to the man page for that superclass. XmManager Resource Set Class: XmCBottomShadowColor Default: dynamic Type: Pixel Access: CSG Class: XmCBottomShadowPixmap Default: XmUNSPECIFIED_PIXMAP Type: Pixmap Access: CSG Class: XmCForeground Default: dynamic Type: Pixel Access: CSG Class: XmCCallback Default: NULL Type: XtCallbackList Access: C Class: XmCHighlightColor Default: dynamic Type: Pixel Access: CSG Class: XmCHighlightPixmap Default: dynamic Type: Pixmap Access: CSG Class: XmCInitialFocus Default: NULL Type: Widget Access: CSG Class: XmCNavigationType Default: XmTAB_GROUP Type: XmNaviga- tionType Access: CSG Class: XmCShadowThickness Default: dynamic Type: Dimension Access: CSG Class: XmCStringDirection Default: dynamic Type: XmStringDirection Access: CG Class: XmCTopShadowColor Default: dynamic Type: Pixel Access: CSG Class: XmCTopShadowPixmap Default: dynamic Type: Pixmap Access: CSG Class: XmCTraversalOn Default: True Type: Boolean Access: CSG Class: XmCUnitType Default: dynamic Type: unsigned char Access: CSG Class: XmCUserData Default: NULL Type: XtPointer Access: CSG Composite Resource Set Class: XmCReadOnly Default: NULL Type: WidgetList Access: G Class: XmCInsertPosition Default: NULL Type: XtOrderProc Access: CSG Class: XmCReadOnly Default: 0 Type: Cardinal Access: G Core Resource Set Class: XmCAccelerators Default: dynamic Type: XtAccelerators Access: CSG Class: XmCSensitive Default: dynamic Type: Boolean Access: G Class: XmCBackground Default: dynamic Type: Pixel Access: CSG Class: XmCPixmap Default: XmUNSPECIFIED_PIXMAP Type: Pixmap Access: CSG Class: XmCBorderColor Default: XtDefaultForeground Type: Pixel Access: CSG Class: XmCPixmap Default: XmUNSPECIFIED_PIXMAP Type: Pixmap Access: CSG Class: XmCBorderWidth Default: 0 Type: Dimension Access: CSG Class: XmCColormap Default: dynamic Type: Colormap Access: CG Class: XmCDepth Default: dynamic Type: int Access: CG Class: XmCCallback Default: NULL Type: XtCallbackList Access: C Class: XmCHeight Default: dynamic Type: Dimension Access: CSG Class: XmCInitialResourcesPersistent Default: True Type: Boolean Access: C Class: XmCMapped- WhenManaged Default: True Type: Boolean Access: CSG Class: XmCScreen Default: dynamic Type: Screen * Access: CG Class: XmCSensitive Default: True Type: Boolean Access: CSG Class: XmCTranslations Default: dynamic Type: XtTranslations Access: CSG Class: XmCWidth Default: dynamic Type: Dimension Access: CSG Class: XmCPosition Default: 0 Type: Position Access: CSG Class: XmCPosition Default: 0 Type: Posi- tion Access: CSG Translations XmFrame inherits translations from XmManager. SEE ALSO
Composite(3X), Constraint(3X), Core(3X), XmCreateFrame(3X), XmManager(3X) XmFrame(3X)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy