Sponsored Content
Top Forums Shell Programming and Scripting Adding strings to lines in a file Post 302356321 by danmero on Friday 25th of September 2009 10:35:43 AM
Old 09-25-2009
Another way:

---------- Post updated at 10:35 AM ---------- Previous update was at 07:04 AM ----------

Code:
awk '{$0=(NR<3)?$0FS"Header"NR:$0FS"Account"}1' file


Last edited by danmero; 09-25-2009 at 11:47 AM.. Reason: Fix error
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting the lines between 2 strings of a file

Hi, I have a sql file and i need to extract the table names used in the sql file using a unix script. If i can extract the lines between the keywords 'FROM' and 'WHERE' in the file, my job is done. can somebody tell me how to do this using a shell script. If u can just let me know, how to... (2 Replies)
Discussion started by: babloo
2 Replies

2. UNIX for Dummies Questions & Answers

Counting no of lines between two strings in a file

Hi all, I'm very very new to UNIX and AWK world.Please help me in finding a solution for my problem. I'm having a file like this ----------------------------------------------------------------- ~Version Information VERS. 2.0: CWLS log ASCII Standard -VERSION 2.0 WRAP. ... (4 Replies)
Discussion started by: santyshyam
4 Replies

3. Shell Programming and Scripting

Adding Strings to a file

Well thanks a lot but I have another Problem I try to solve. I habe one simple Textfile with entries like this, for example: file1 file2 file3 file4 ... file200 And I want to add Strings at the beginning on the line. Like this word1 file1 word1 file2 ... I hope you can help me (3 Replies)
Discussion started by: Blackbox
3 Replies

4. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

5. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

6. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

7. UNIX for Dummies Questions & Answers

Editing strings within lines of file

Dear All, I have a file which contains a column with age, which is represented in two following patterns 1. "007/A" or ''007/a" or ''7 /a" ..... In this case A or a means year and I would like to extract only the numeric values eg 7 in the above case if this pattern exits in a line of file.... (5 Replies)
Discussion started by: pawannoel
5 Replies

8. Shell Programming and Scripting

Egrep strings on different lines in file

test.txt: appleboy orangeletter sweetdeal catracer conducivelot I want to only grep out lines that contain "appleboy" AND "sweetdeal". however, the closest thing to this that i can think of is this: cat test.txt | egrep "appleboy|sweetdeal" problem is this only searches for all... (9 Replies)
Discussion started by: SkySmart
9 Replies

9. UNIX for Dummies Questions & Answers

Add strings from one file at the end of specific lines in text file

Hello All, this is my first post so I don't know if I am doing this right. I would like to append entries from a series of strings (contained in a text file) consecutively at the end of specifically labeled lines in another file. As an example: - the file that contains the values to be... (3 Replies)
Discussion started by: gus74
3 Replies

10. Shell Programming and Scripting

Trying to take file numbers from a file, pass them to sed to change strings in corresponding lines

I have a bunch of file numbers in the file 'test': I'm trying the above command to change all the instances of "H" to "Na+" in the file testsds.pdb at the line numbers indicated in the file 'test'. I've tried the following and various similar alternatives but nothing is working: cat test |... (3 Replies)
Discussion started by: crunchgargoyle
3 Replies
XtInstallAccelerators() 												   XtInstallAccelerators()

Name
  XtInstallAccelerators - install a widget's accelerators on another widget.

Synopsis
  void XtInstallAccelerators(destination, source)
	 Widget destination;
	 Widget source;

Inputs
  destination
	    Specifies  the widget in which events specified in the accelerator table will be detected.	Must be of class Core or any subclass
	    thereof.

  source    Specifies the widget whose actions will be invoked when events occur in destination.  Must be  of  class  Core  or	any  subclass
	    thereof.

Description
  XtInstallAccelerators()  merges  the accelerator table of source into the translation table of destination.  After this call, events in the
  destination widget will trigger actions in the source widget.

  If the display_accelerator() method of source is non-NULL, XtInstallAccelerators() calls it with source and a canonical  representation  of
  the accelerator table that was installed.  This method is a hook that is intended to allow a widget to dynamically modify its appearance (a
  menu button might display the key sequence that will invoke it, for example) when an accelerator is installed.

Usage
  It is often convenient to be able to bind events in one widget to actions in another.  In particular, it is often  useful  to  be  able  to
  invoke menu actions from the keyboard.  The Intrinsics provide a facility, called accelerators, that let you accomplish this.  An accelera-
  tor table is a translation table that binds events in the destination widget to actions in the source widget.  The accelerator table can be
  installed  on  one or more destination widgets.  When an event sequence in destination would cause an accelerator action to be invoked, and
  if the source widget is sensitive, the actions are executed as though triggered by the same event sequence in source.  The event is  passed
  to the action procedure without modification.  The action procedures used within accelerators must assume neither that the source widget is
  realized, nor that any fields of the event are in reference to the source widget's window if the widget is realized.

  Every widget includes an XtNaccelerators resource, which is defined by the Core widget class.  The actual value of  this  resource  can  be
  hardcoded by the application or set in a resource file, just like any other resource.

  In  order for the XtNaccelerators resource to actually be used, however, the application must call XtInstallAccelerators() (or XtInstallAl-
  lAccelerators()).  This call takes two arguments.  The destination widget is the widget whose translation table will be augmented with  the
  accelerator table from the source widget.

  It  is  difficult to remember which of the two widgets in this call is which.  If you want to install a keyboard accelerator so that a key-
  stroke in a text widget invokes an action in a menu button, then the menu button is the source, and the text	widget	is  the  destination.
  You must set the accelerator table in the XtNaccelerators resource of the menu button, and then install those accelerators on the text wid-
  get.

  If you are programming with the Motif widget set, you will generally not be able to use accelerators as described here.  Motif  provides  a
  different (and incompatible) style of accelerators for use with menus; see Volume 6, Motif Programming Manual for more information.

Example
  Assume  an  application  whose  top-level shell widget is named topLevel, and which contains a Command widget instance named quit.  Further
  assume that the quit widget has the following XtNaccelerators resource defined for it:

	*quit.accelerators:	 <KeyPress>q: notify()

  The call:

	XtInstallAccelerators (topLevel, quit);

  would allow a "q" typed in the application's top-level window to invoke the quit widget's notify action.  The  notify  action  invokes  the
  callback list of the button, and assuming that a quit callback was registered, causes the application to terminate.

See Also
  XtInstallAllAccelerators(1),
  display_accelerator(4).

Xt - Translations and Actions												   XtInstallAccelerators()
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy