Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to replace character on defined position Post 302334981 by necroman08 on Friday 17th of July 2009 02:15:30 AM
Old 07-17-2009
That's right.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Character position

Hi , I am required to view the fixed postion file very often . I am looking for the utility like this if the file has a one or multile line abcdefghijklmnopqr Utility should make my file look like this 12345678910111213141516-------------------------- abcdefghijk l m n o p q r ... (4 Replies)
Discussion started by: akrathi
4 Replies

2. Shell Programming and Scripting

Using sed to replace specific character and specific position

I am trying to use sed to replace specific characters at a specific position in the file with a different value... can this be done? Example: File: A0199999123 A0199999124 A0199999125 Need to replace 99999 in positions 3-7 with 88888. Any help is appreciated. (5 Replies)
Discussion started by: programmer22
5 Replies

3. Shell Programming and Scripting

How to remove a defined character on an array variable in a do while statement in ksh

I have a korn shell code here on a while do statement which replace the string stored on an array removing double quotes characters on it but it doesn't work. example record: appointmentDate = "tree" which value should result to tree #!/bin/ksh # Remove " on string records let recordCount=3... (5 Replies)
Discussion started by: ryukishin_17
5 Replies

4. Shell Programming and Scripting

Count number of occurences of a character in a field defined by the character in another field

Hello, I have a text file with n lines in the following format (9 column fields): Example: contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the... (3 Replies)
Discussion started by: s052866
3 Replies

5. Shell Programming and Scripting

Replace character in certain position in a string

Hello everyone this is my first post of many to come :) I am writing a script and in this script at one point i need to replace a character in a particular position in a string for example: in the string "mystery" i would need to replace the 3rd position to an "r" so the string becomes... (3 Replies)
Discussion started by: snipaa
3 Replies

6. Emergency UNIX and Linux Support

Replace nth position character of all the lines in file

I want to replace 150th character of all the lines in a file using sed or awk... searched the forums but didn't find exact answer (9 Replies)
Discussion started by: greenworld123
9 Replies

7. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 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. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies

10. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies
DtEditorReplace(library call)											     DtEditorReplace(library call)

NAME
DtEditorReplace -- replace a portion of the contents of a DtEditor widget SYNOPSIS
#include <Dt/Editor.h> DtEditorErrorCode DtEditorReplace( Widget widget, XmTextPosition startPos, XmTextPosition endPos, DtEditorContentRec *data); DESCRIPTION
The DtEditorReplace function replaces part of the contents of a DtEditor widget with a string, a wide character string or sized buffer. The data is transferred to the DtEditor widget using a DtEditorContentRec, which indicates the type of data being transferred along with the actual data. All data following the start position and up to, but not including, the end position is replaced. If the start position and the end position are equal, the data is inserted after the end position. The character positions begin at zero and are numbered sequentially from the beginning of the text. After the replacement, the insertion cursor is positioned after the last character inserted. The widget argument specifies the DtEditor widget ID. The startPos argument specifies the starting character position of the portion to replace. The replacement begins at this character. The endPos argument specifies the ending character position of the portion to replace. The replacement ends before this character. The data argument is a pointer to the data structure containing the data to insert. For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3). For a complete definition of DtEditorContentRec, see Dt/Editor.h - DtEditor(5). RETURN VALUE
Upon successful completion, the DtEditorReplace function returns one of the following values: DtEDITOR_NO_ERRORS The data was replaced sucessfully. DtEDITOR_NULLS_REMOVED NULL characters were found and removed from the data. Otherwise, if the DtEditorReplace function cannot replace the data in the DtEditor widget, it returns one of the following values: DtEDITOR_INVALID_TYPE The Type field is not recognized. DtEDITOR_INVALID_RANGE The startPos argument is greater than the endPos argument. DtEDITOR_ILLEGAL_SIZE The size of the buffer passed in is negative. DtEDITOR_NULL_ITEM The data buffer is NULL. DtEDITOR_INSUFFICIENT_MEMORY Not enough system memory is available to replace the data. EXAMPLES
The following code segment modifies the contents of a DtEditor widget to ``The quick fox.'' Widget editor; DtEditorContentRec cr; DtEditorErrorCode status; XmTextPosition start = (XmTextPosition) 4, end = (XmTextPosition) 9; char *sampleString1="The brown fox", *sampleString2="quick"; cr.type = DtEDITOR_TEXT; cr.value.string = sampleString1; status = DtEditorSetContents(editor, &cr); if (status != DtEDITOR_NO_ERRORS && status != DtEDITOR_NULLS_REMOVED) { printf("Unable to set contents of the widget "); } else { cr.type = DtEDITOR_TEXT; cr.data.string = sampleString2; status = DtEditorReplace(editor, start, end, &cr); if (status != DtEDITOR_NO_ERRORS) printf("Unable to replace part of the widget contents "); } APPLICATION USAGE
If the data is in a disk file, rather than in memory, the application should use DtEditorReplaceFromFile(3). SEE ALSO
Dt/Editor.h - DtEditor(5), DtEditor(3), DtEditorAppend(3), DtEditorAppendFromFile(3), DtEditorGetContents(3), DtEditorInsert(3), DtEdi- torInsertFromFile(3), DtEditorReplaceFromFile(3), DtEditorSaveContentsToFile(3), DtEditorSetContents(3), DtEditorSetContentsFromFile(3). DtEditorReplace(library call)
All times are GMT -4. The time now is 03:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy