Sponsored Content
Top Forums Shell Programming and Scripting Help needed in character replacement in Korn Shell Post 302112572 by zazzybob on Thursday 29th of March 2007 02:35:58 AM
Old 03-29-2007
Depending on your version of sed something like this may work for you:
Code:
$ sed -e 's! !/!1' -e 's/ /     /2' infile > outfile

If that doesn't work, the "longhand" version will....
Code:
$ sed -e 's/^\([^ ]*\) \([^ ]*\) \([^ ]*\) \(.*\)$/\1\/\2 \3     \4/' infile > outfile

Cheers
ZB
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Shell Help Needed

How do I change directories to a path given by input variable in Korn Shell? e.g. I tired with the Korn Shell below but it doesn't work. ---------------------------------- #!/bin/ksh echo "Enter folder name: \c" read folder cd $folder ---------------------------------- Any help will... (5 Replies)
Discussion started by: stevefox
5 Replies

2. Shell Programming and Scripting

Character replacement

Hi, I am working on a command that replaces some occurrences of quotation marks in file. The quotation mark cannot be the first or the last character in line and cannot be preceded or followed by a comma. I am not an expert in regular expressions, but I managed to create the following... (2 Replies)
Discussion started by: piooooter
2 Replies

3. Shell Programming and Scripting

KSH - Character Replacement

Hey all. Easy question. I have a (ksh) varaible x. It contains the following (for example): N557788 I want to replace the "N" with a "-". I've done this before but for the life of me I cannot remember how I did it. Thanks. mtw (2 Replies)
Discussion started by: mixxamike
2 Replies

4. Shell Programming and Scripting

Korn Shell script needed

Hi all, I need a Korn Shell script that will go out to all Unix Servers and pull all non humans IDs from them while at the same time produce a file to show which servers we have access to and which ones we don't. Thanks in advance. (5 Replies)
Discussion started by: vinsara
5 Replies

5. UNIX for Dummies Questions & Answers

banner character replacement

Can we able to replace the character # in banner command with some other characters. Can we able to blink the character in Kornshell (1 Reply)
Discussion started by: sivakumar.rj
1 Replies

6. Shell Programming and Scripting

Korn: How to loop through a string character by character

If I have a string defined as: MyString=abcde echo $MyString How can I loop through it character by character? I haven't been able to find a way to index the string so that I loop through it. shew01 (10 Replies)
Discussion started by: shew01
10 Replies

7. Shell Programming and Scripting

Line Replacement help needed.

I have a file called vm.cfg which looks like follows # cat vm.cfg acpi = 1 apic = 1 builder = 'hvm' device_model = '/usr/lib/xen/bin/qemu-dm' disk = kernel = '/usr/lib/xen/boot/hvmloader' memory = '300' name = 'vm_temp' on_crash = 'restart' on_reboot = 'restart' pae = 1 serial =... (5 Replies)
Discussion started by: pinga123
5 Replies

8. Shell Programming and Scripting

delete new line character ( - ) , korn shell

Hi guys , i need help so bad on this issue.. Basically i have to delete the line continuation symbol of first column variable and add the truncated part of that word in next line to first line. here i written sample 3 lines but originally i have bunch of lines in that file. client1_day- ... (3 Replies)
Discussion started by: chrismorgan
3 Replies

9. Shell Programming and Scripting

Help needed in Korn Shell scripting

#! /bin/ksh while read line do if ] ; then echo "no data" continue; fi echo "performing operation on $line" done < prg.txt (3 Replies)
Discussion started by: Juhi Kashyap
3 Replies

10. Shell Programming and Scripting

Help Needed with File Checker Korn Shell Script

I am attempting to write a korn shell script that does the following, but I am getting errors. I'm new to korn shell scripting and am not sure what I am doing wrong. Please help with example scripts. Thanks. 1) check for day of the week 2) if day of the week is Monday then check for the... (4 Replies)
Discussion started by: ijmoore
4 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 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy