Sponsored Content
Top Forums Shell Programming and Scripting Grep string in a file and paste next line in a specific way Post 303022018 by RudiC on Thursday 23rd of August 2018 02:46:27 AM
Old 08-23-2018
What in the solution proposed doesn't satisfy your request?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

copy and paste a specific line

Hi I am having some trouble cut and paste a file based on the content of another file. I have a file called draft. I need to cut and paste its content to another file based on the content of a file called proc.txt The content of proc.txt is like the following:... (7 Replies)
Discussion started by: tiger99
7 Replies

2. Shell Programming and Scripting

grep on specific line of the file

Hi, how can we search for a word (with case ignore )on specific line numbers ex: Awk /^regEX/ with condition on first line or second line Awk/^ regex1/ on line 1 Awk /^regEX2/ on line 3 thanks in advance (4 Replies)
Discussion started by: rider29
4 Replies

3. Shell Programming and Scripting

grep a specific line from a file

Is there a way to grep only one line from a file listing name of files? If I use head -1 it's ok(the first line only) If I use head -2 it's not good because I have already checked the first line. I'd like something like this: while test $i -le $max do grep "$3" `head -$i temp.txt` >... (4 Replies)
Discussion started by: Max89
4 Replies

4. Shell Programming and Scripting

Deleting a line from a file based on one specific string instance?

Hello! I need to delete one line in a file which matches one very precise instance of a string only. When searching the forum I unfortunately only found a solution which would delete each line on which a particular string occurs. Let's assume I have a file composed of thousands of lines... (4 Replies)
Discussion started by: Black Sun
4 Replies

5. Shell Programming and Scripting

Remove a specific line from grep output string

Dear All I want to search string "1000" from input file and if it found i want remove line that contain 1000 and also remove 3 line above it and 2 line below it. INPUT FILE: BHAT-D 2 aaa ID CODE GS UPDATE MODE LANG MCO MCL NUMPAGES 50 ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

6. Programming

How to grep the specific string or user's list from the file

I have a file on UNIX system from where I want to grep the list of all users associated to the particular repository.If the user's list is in single line then I fetch all list but if it is in two separate lines it doesn't.I use the below command a=KESTREL-DEV;b=users;cat access_file|grep... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

7. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

8. Shell Programming and Scripting

How to grep an empty line in a specific column of a file?

Suppose i have the following data : cat file.txt 12431,123334,55353,546646,14342234,4646,35234 123123,3535,123434,132535,1234134,13535,123534 123213,545465,23434,45646,2342345,4656,31243 2355425,2134324,53425,342,35235,23434,234535 3423424,234234,65465,,2344,35436,234524,234... (7 Replies)
Discussion started by: Ravi Tej
7 Replies

9. UNIX for Dummies Questions & Answers

Commenting a line matched with a specific string in a file

Hi, I would like to comment a line that matched a string "sreenivas" in a file without opening it. Thanks in advance. Regards, Sreenivas (3 Replies)
Discussion started by: raosr020
3 Replies

10. Shell Programming and Scripting

Grep pattern after specific line number in a file

Hi guys, I am running a while loop in a script ro read a file line by line. Now I want to run a grep only on the lines below the line I am that is being read by the while loop. Eg: If my while loop is on line 4 of the file, the grep only runs below line 4 and does not include line 1,2... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies
query_geometry()														  query_geometry()

Name
  query_geometry - RectObj method called to request a widget's preferred size and position.

Synopsis
  typedef XtGeometryResult (*XtGeometryHandler)(Widget, XtWidgetGeometry *,
  XtWidgetGeometry *);
	   Widget w;
	   XtWidgetGeometry *request;
	   XtWidgetGeometry *preferred_return

Inputs
  w	    Specifies the widget or object that is being queried.

  request   Specifies the geometry changes that the parent plans to make.

Outputs
  preferred_return
	    Returns the widget or object's preferred geometry.

Returns
  The widget's reply: XtGeometryYes, XtGeometryNo, or XtGeometryAlmost.

Description
  The  query_geometry()  method  is  registered  on  the  query_geometry field of the RectObj or Core class part structure.  It is invoked by
  XtQueryGeometry() when the widget's parent wants to determine the widget's preferred geometry.  The parent may call this function  when  it
  want	to  know  the  widget's ideal size in the absence of any constraints, or it may call it before changing some of the widget's geometry
  fields in order to find out the widget's preference for the other fields.

  The request argument indicates the geometry changes the parent plans to make.  request->request_mode contains flags that indicate which  of
  the  remaining  fields  are  significant.  (See the "Structures" section below for a description of the structure and a list of the flags.)
  The query_geometry() method should examine this proposed change, set its preferred geometry in preferred_return, setting preferred_return->
  request_mode to indicate which geometry field it cares about, and return one of the following values:

  XtGeometryYes
       The widget agrees to the change; the parent should make exactly the change it proposed.	When query_geometry() returns this value, the
       contents of preferred_return should be identical to the contents of request, for each flag bit set in  preferred_return.   This	means
       that  the  parent's  proposed  geometry	is exactly the widget's preferred geometry (or that the widget has a flexible notion of "pre-
       ferred" and feels that the proposal is good enough).

  XtGeometryNo
       This return value means that the widget's current geometry is its preferred geometry, and it would rather not be changed.   When  this
       value  is  returned, query_geometry() doesn't have to fill in preferred_return, because XtQueryGeometry() will fill in any unspecified
       fields with their current values, which in this case are the preferred values.  It is of course up to the parent widget whether or not
       to honor this request not to change.

  XtGeometryAlmost
       This return value means that the widget would like a geometry change, but that its preferred geometry differs from the proposed geome-
       try.  query_geometry() should return this value if at least one bit is set in the return flags that was not set in the proposed flags,
       or if any of the returned values (that have their flag bit set) differ from the corresponding proposed values.

  Note	that query_geometry() need only return its preferences for the fields it cares about (generally width and height).  XtQueryGeometry()
  will fill in any unspecified fields with the widget's current value.	Also, query_geometry() can ignore flag bits set in request for fields
  that	it  does  not  care  about.  If a widget doesn't care about its location, for example, and its parent proposes to change its location
  without changing its size, it should still place its preferred size in preferred_return, and follow the  rules  above  to  determine	which
  value to return.

  It  is  up to the parent widget to decide what to do with the return value from this function (which it gets from XtQueryGeometry()).  Some
  parents will respect the widget's requests, but many will ignore them.  Generally, if a parent sets a flag in request, it will change  that
  field,  regardless  of  the  widget's  return value.	The power of the query_geometry() method lies in the fact that the widget can propose
  additional geometry changes with the XtGeometryAlmost return value.  A parent that constrains the width of a widget may call	XtQueryGeome-
  try()  to  determine	how high the widget would like to be, given its new width.  A label widget that supported word wrapping, for example,
  might request a larger height if its width were made smaller.  A cooperating parent would make its change to the width, but also change the
  height as the child requested.

  The  query_geometry() method is not chained.	Widget classes that do not define a query_geometry() method can inherit the method from their
  superclass by specifying XtInheritQueryGeometry on the query_geometry field of the RectObj or Core class part structure.  Widgets that have
  no preference about their geometry can set this field to NULL.

  See  the  "Background"  section below for more details on the query_geometry() method.  See XtQueryGeometry(1) for the parent widget's per-
  spective on this geometry negotiation process.

Usage
  Like the geometry_manager() method, the query_geometry() method  can	be  confusing,	and  can  become  almost  arbitrarily  complex.   The
  query_geometry() mechanism allows much more flexibility than most widgets need and more than most parents support.  The fact that there are
  three possible return values which do not have very clearly defined meanings (at least not well defined in practice) to the child or to the
  parent makes the situation all the more confusing.  There are some factors that can simplify the query_geometry() method, however.

  Most	widgets  do  not  care about anything other than their width and height, and their query_geometry() methods never need to return pre-
  ferred information about position, border width, or stacking order.  Most parents won't bother to query these fields anyway.

  Most widgets treat their width and height independently, and do not try to increase their height  if	their  width  shrinks,	for  example.
  These widgets can use a simple method like the example shown below.

  Some widgets do not even have a preference about their size.	A label widget's preferred size is whatever it takes to display the string or
  pixmap, and a composite widget's preferred size may be whatever it takes to lay out its children.  A scrollbar, however, can make  do  with
  whatever size it is given, and can simply inherit the query_geometry() method of its parent.

Example
  The  following  procedure  is  the query_geometry() method from the Xaw Label widget.  Most of the Xaw widgets that have a query_geometry()
  method use almost identical procedures.  The first thing it does is set its preferred width and height, which are the width and  height  of
  the  label  plus internal margins.  Then it checks to see if the parent's requested geometry had both width and height flags set (note that
  it masks out any other bits for fields that it does not care about), and if so, and if the parent's request matches the preferred size,  it
  returns  XtGeometryYes.   Otherwise,	if  the  preferred  size matches the widget's current size, it returns XtGeometryNo, and otherwise it
  returns XtGeometryAlmost.

  Note that this procedure does not attempt to do anything special if only its width or only its height are  constrained.   The  query_geome-
  try() method of the Xaw Box widget does handle this case, and may be worth study if you will be writing a similar widget.

     static XtGeometryResult QueryGeometry(w, intended, preferred)
	 Widget w;
	 XtWidgetGeometry *intended, *preferred;
     {
	 register LabelWidget lw = (LabelWidget)w;

	 preferred->request_mode = CWWidth   CWHeight;
	 preferred->width = (lw->label.label_width + 2 * lw->label.internal_width +
			     LEFT_OFFSET(lw));
	 preferred->height = lw->label.label_height + 2*lw->label.internal_height;

	 if (  ((intended->request_mode & (CWWidth   CWHeight))
		     == (CWWidth   CWHeight)) &&
	       intended->width == preferred->width &&
	       intended->height == preferred->height)
	     return XtGeometryYes;
	 else if (preferred->width == w->core.width &&
		  preferred->height == w->core.height)
	     return XtGeometryNo;
	 else
	     return XtGeometryAlmost;
     }

Background
  The  query_geometry()  method  is expected to examine the bits set in request->request_mode, evaluate the proposed geometry for the widget,
  and store the result in preferred_return (setting the bits in preferred_return-> request_mode corresponding to those geometry  fields  that
  it  cares  about).   If the proposed geometry change is acceptable without modification, the query_geometry() method should return XtGeome-
  tryYes.  If at least one field in preferred_return is different from the corresponding field in request  or  if  a  bit  was	set  in  pre-
  ferred_return  that was not set in request, the query_geometry() method should return XtGeometryAlmost.  If the preferred geometry is iden-
  tical to the current geometry, the query_geometry() method should return XtGeometryNo.

  Note that the query_geometry() method may assume that no XtMakeResizeRequest() or XtMakeGeometryRequest() is in progress for the  specified
  widget;  that  is, it is not required to construct a reply consistent with the requested geometry if such a request were actually outstand-
  ing.

  After calling the query_geometry() method or if the query_geometry() field is NULL, XtQueryGeometry() examines all the unset bits  in  pre-
  ferred_return->  request_mode  and  sets  the  corresponding fields in preferred_return to the current values from the widget instance.  If
  CWStackMode is not set, the stack_mode field is set to  XtSMDontChange.   XtQueryGeometry()  returns	either	the  value  returned  by  the
  query_geometry() method or XtGeometryYes if the query_geometry() field is NULL.

  Therefore,  the  caller can interpret a return of XtGeometryYes as not needing to evaluate the contents of the reply and, more importantly,
  not needing to modify its layout plans.  A return of XtGeometryAlmost means either that both the parent and the child expressed interest in
  at least one common field and the child's preference does not match the parent's intentions or that the child expressed interest in a field
  that the parent might need to consider.  A return value of XtGeometryNo means that both the parent and the child expressed  interest	in  a
  field  and  that  the child suggests that the field's current value is its preferred value.  In addition, whether or not the caller ignores
  the return value or the reply mask, it is guaranteed that the preferred_return structure contains complete  geometry	information  for  the
  child.

  Parents are expected to call XtQueryGeometry() in their layout routine and wherever other information is significant after change_managed()
  has been called.  The change_managed() method may assume that the child's current geometry is its preferred geometry.  Thus, the  child  is
  still responsible for storing values into its own geometry during its initialize() method.

Structures
  The possible return values of a query_geometry() method are defined as follows:

     typedef enum {
	 XtGeometryYes,   /* Request accepted */
	 XtGeometryNo,	  /* Request rejected */
	 XtGeometryAlmost,/* Compromise proposed */
	 XtGeometryDone   /* never returned by query_geometry */
     } XtGeometryResult;

  The XtWidgetGeometry structure is similar to but not identical to the corresponding Xlib structure:

     typedef unsigned long XtGeometryMask;
     typedef struct {
	 XtGeometryMask request_mode;
	 Position x, y;
	 Dimension width, height;
	 Dimension border_width;
	 Widget sibling;
	 int stack_mode;
     } XtWidgetGeometry;

  XtQueryGeometry(), like the Xlib XConfigureWindow() function, uses request_mode to determine which fields in the XtWidgetGeometry structure
  the parent and the child have set.  The request_mode definitions are from <X11/X.h>:

     #define		 CWX(1<<0)
     #define		 CWY(1<<1)
     #define		 CWWidth(1<<2)
     #define		 CWHeight(1<<3)
     #define		 CWBorderWidth(1<<4)
     #define		 CWSibling(1<<5)
     #define		 CWStackMode(1<<6)

  The stack_mode definitions are from <X11/X.h>:

     #define		 Above0
     #define		 Below1
     #define		 TopIf2
     #define		 BottomIf3
     #define		 Opposite4

  The Intrinsics also support the following value:

     #define		 XtSMDontChange5

  For precise definitions of Above, Below, TopIf, BottomIf, and Opposite, see the reference page for XConfigureWindow() in  Volume  Two, Xlib
  Reference Manual.  XtSMDontChange indicates that the widget wants its current stacking order preserved.

See Also
  XtQueryGeometry(1),
  Core(3).

Xt - Intrinsics Methods 													  query_geometry()
All times are GMT -4. The time now is 06:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy