Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to insert a string and variable at specified position in command in bash? Post 303042168 by rbatte1 on Tuesday 17th of December 2019 07:35:10 AM
Old 12-17-2019
From my suggestion in post 5, I'm sure you can attempt to replace the sub-process on line 2 (the bit between $( and )) such that the output it creates uses a loop based on a counter to create the required number of rows, but then, however would would handle it if one of the files didn't exist?

Please give us the actual problem you are trying to solve, with the actual conditional, the actual logic and the actual files listed in the actual directory and we might actually be able to help you. Otherwise we're just guessing at what you need help with.





Thanks, in advance,
Robin
These 2 Users Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find a position and print some string in the next and same position

I need a script for... how to find a position of column data and print some string in the next line and same position position should find based on *HEADER8* in text for ex: ord123 abs 123 987HEADER89 test234 ord124 abc 124 987HEADER88 test235 ... (1 Reply)
Discussion started by: naveenkcl
1 Replies

2. Shell Programming and Scripting

search a line and insert string into specific at position

Hi, guys. I have one question: How can I search for a line with certain string in it and then insert a string into this line? For example: There is a file called shadow, the contents of it are below: ************************** ... yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies

3. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

4. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. Shell Programming and Scripting

Insert charactera in 1st position of specific lines using vi editor or sed command

Dear all, i am having text file like below surya rama ranga laxman rajesh reddy i want add string (OK) before a text from line 3 to 5 the result will be surya rama OK ranga OK laxman OK rajesh reddy (1 Reply)
Discussion started by: suryanarayana
1 Replies

7. Shell Programming and Scripting

Need command or script to print all lines from 2nd position to last but one position

hi guys, i want command or script to display the content of file from 2nd position to last but one position of a file abcdefghdasdasdsd 123,345,678,345,323 434,656,656,656,656 678,878,878,989,545 4565656667,65656 i want to display the same above file without first and... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. Shell Programming and Scripting

Search for a string at a particular position and replace with blank based on position

Hi, I have a file with multiple lines(fixed width dat file). I want to search for '02' in the positions 45-46 and if available, in that lines, I need to replace value in position 359 with blank. As I am new to unix, I am not able to figure out how to do this. Can you please help me to achieve... (9 Replies)
Discussion started by: Pradhikshan
9 Replies

9. UNIX for Beginners Questions & Answers

Bash: Insert in a variable a file

hi all i have a problem in the bash shell. i'd like insert in a variable a file for example : i have a file datafine.log in this file there is : 17/JUN/2019 i want to insert the value of datafine.log in a variable. Regards Frncesco edit by bakunin: please use CODE-tags for your data... (2 Replies)
Discussion started by: Francesco_IT
2 Replies

10. UNIX for Beginners Questions & Answers

How to insert subnode in xml file using xmlstarlet or any other bash command?

I have multiple xml files where i want to update a subnode if the subnode project points to different project or insert a subnode if it doesn't exist using a xmlstarlet or any other command that can be used in a bash script. I have been able to update the subnode project if it doesn't point to... (1 Reply)
Discussion started by: Sekhar419
1 Replies
XGetWindowProperty()													      XGetWindowProperty()

Name
  XGetWindowProperty - obtain the atom type and property format for a window.

Synopsis
  int XGetWindowProperty(display, w, property, long_offset, long_length,
       delete, req_type, actual_type_return, actual_format_return, nitems_return, bytes_after_return, prop_return)
	Display *display;
	Window w;
	Atom property;
	long long_offset, long_length;
	Bool delete;
	Atom req_type;
	Atom *actual_type_return;
	int *actual_format_return;
	unsigned long *nitems_return;
	unsigned long *bytes_after_return;
	unsigned char **prop_return;

Arguments
  display   Specifies a connection to an X server; returned from XOpenDisplay().

  w	    Specifies the ID of the window whose atom type and property format you want to obtain.

  property  Specifies the atom of the desired property.

  long_offset
	    Specifies the offset in 32-bit quantities where data will be retrieved.

  long_length
	    Specifies the length in 32-bit multiples of the data to be retrieved.

  delete    Specifies a boolean value of True or False.  If you pass True and a property is returned, the property is deleted from the window
	    after being read and a PropertyNotify event is generated on the window.

  req_type  Specifies an atom describing the desired format of the data.  If AnyPropertyType is specified,  returns  the  property  from  the
	    specified  window  regardless of its type.	If a type is specified, the function returns the property only if its type equals the
	    specified type.

  actual_type_return
	    Returns the actual type of the property.

  actual_format_return
	    Returns the actual data type of the returned data.

  nitems_return
	    Returns the actual number of 8-, 16-, or 32-bit items returned in prop_return.

  bytes_after_return
	    Returns the number of bytes remaining to be read in the property if a partial read was performed.

  prop_return
	    Returns a pointer to the data actually returned, in the specified format.  XGetWindowProperty() always allocates one  extra  byte
	    after the data and sets it to NULL.  This byte is not counted in nitems_return.

Returns
  Success on success.  The failure return value is undefined.

Description
  XGetWindowProperty()	gets the value of a property if it is the desired type.  XGetWindowProperty() sets the return arguments acccording to
  the following rules:

  o  If the specified property does not exist for the specified window, then:  actual_type_return is  None;  actual_format_return  =  0;  and
     bytes_after_return = 0.  delete is ignored in this case, and nitems_return is empty.

  o  If  the  specified  property  exists,  but  its  type  does  not  match req_type, then:  actual_type_return is the actual property type;
     actual_format_return is the actual property format (never zero); and bytes_after_return  is  the  property  length  in  bytes  (even  if
     actual_format_return is 16 or 32).  delete is ignored in this case, and nitems_return is empty.

  o  If  the  specified property exists, and either req_type is AnyPropertyType or the specified type matches the actual property type, then:
     actual_type_return is the actual property type; and actual_format_return is the actual property format (never zero).  bytes_after_return
     and nitems_return are defined by combining the following values:

	   N = actual length of stored property in bytes (even if actual_format_return is 16 or 32)
	   I = 4 * long_offset (convert offset from longs into bytes)
	   L = MINIMUM((N - I), 4 * long_length) (BadValue if L < 0)
	   bytes_after = N - (I + L)  (number of trailing unread bytes in stored property)

     The  returned data (in prop_return) starts at byte index I in the property (indexing from 0).  The actual length of the returned data in
     bytes is L.  L is converted into the number of 8-, 16-, or 32-bit items returned by dividing by 1, 2, or 4 respectively and  this	value
     is returned in nitems_return.  The number of trailing unread bytes is returned in bytes_after_return.

  If delete == True and bytes_after_return == 0 the function deletes the property from the window and generates a PropertyNotify event on the
  window.

  When XGetWindowProperty() executes successfully, it returns Success.	The Success return value and the undocumented value returned on fail-
  ure are the opposite of all other routines that return int or Status.  The value of Success is undocumented, but is zero (0) in the current
  sample implementation from MIT.  The failure value, also undocumented, is currently one (1).	Therefore, comparing either value to True  or
  False, or using the syntax "if (!XGetWindowProperty(...))"  is incorrect.

  To free the resulting data, use XFree().

  For more information, see Volume One, Chapter 12, Interclient Communication.

Errors
  BadAtom

  BadValue  Value of long_offset caused L to be negative above.

  BadWindow

See Also
  XChangeProperty(), XGetAtomName(), XGetFontProperty(), XListProperties(), XRotateWindowProperties(), XSetStandardProperties().

Xlib - Properties													      XGetWindowProperty()
All times are GMT -4. The time now is 05:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy