Sponsored Content
Top Forums Shell Programming and Scripting substitute a string on a specific position for specific lines Post 302479952 by ducet8 on Monday 13th of December 2010 11:16:49 AM
Old 12-13-2010
I'm editing my post because I just re-read your post and saw that you are only looking at specific locations on each line. Also, I see that you already tried sed. I believe awk will accept a period for a single character. You could try using a while loop to read each line (while line=$(line)) and checking for a successful status on an awk command like: awk '/^........TOCHANGE/' $line. If that is successful, you could then use a sed (newline = `sed -e 's/TOCHANGE/ABCABCAB' $line`).

My apologies for the confusion, but I hope it helps. By the way, I didn't have a file like this to try. So, these are untried suggestions.

Last edited by ducet8; 12-13-2010 at 01:31 PM.. Reason: wrong information
ducet8
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add character in specific position of a string?

Hi All, I would like to use sed to add "-" between the following string: Value: 20060830 Result: 2006-08-30 Pls advice. Thx a lot Victor (5 Replies)
Discussion started by: victorlung
5 Replies

2. Shell Programming and Scripting

Print lines with search string at specific position

Hi Folks, I have a file with all fields defined by byte position, but any field can be empty so I cannot print lines based on a search of specific columns. I need to print all lines of this file where the string of two characters at byte position 100-101 contains the number 27. Any ideas? ... (4 Replies)
Discussion started by: HealthyGuy
4 Replies

3. Shell Programming and Scripting

check position of end of line for some specific lines

-------------------------------------------------------------------------------- Have to check in a file that the lines starting with 620 and 705 are ending at same posiotin. 82012345 62023232323 70523949558 62023255454 9999 In the above lines, i have to check the lines starting... (1 Reply)
Discussion started by: senthil_is
1 Replies

4. Shell Programming and Scripting

Substitute specific lines with lines from another file

Hello All, I am new to this forum. I am currently facing a problem in manipulating files. I have two files called old-matter and new-matter # cat old-matter abc: this, is a, sample, entry byi: white board, is white in color rtz: black, board is black qty: i tried, a lot asd: no... (1 Reply)
Discussion started by: rahmathulla
1 Replies

5. 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

6. Shell Programming and Scripting

Print lines with specific character at nth position in a file

I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (2 Replies)
Discussion started by: manaswinig
2 Replies

7. Shell Programming and Scripting

Print lines with specific character at nth position in a file

I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (1 Reply)
Discussion started by: manaswinig
1 Replies

8. 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

9. Shell Programming and Scripting

AWK or SED to add string at specific position

Greetings. I don't have experience programing scripts. I need to insert a string in a specific position of another string on another file (last.cfg), for example: File last.cfg before using script: login_interval=1800 lcs.machinename=client04 File last.cfg after using script:... (4 Replies)
Discussion started by: vanesuke
4 Replies

10. Shell Programming and Scripting

Using sed to replace a string in a specific position

I asked this before, but my problem got more complicated. Heres what I am trying to do: I'm trying to replace a string at a certain location with another string. Heres the file I'm trying to change: \E I want to replace the escape code at the 3rd line, 2nd column with this escape code... (3 Replies)
Discussion started by: tinman47
3 Replies
SD_JOURNAL_GET_CURSOR(3)				       sd_journal_get_cursor					  SD_JOURNAL_GET_CURSOR(3)

NAME
sd_journal_get_cursor, sd_journal_test_cursor - Get cursor string for or test cursor string against the current journal entry SYNOPSIS
#include <systemd/sd-journal.h> int sd_journal_get_cursor(sd_journal* j, char ** cursor); int sd_journal_test_cursor(sd_journal* j, const char * cursor); DESCRIPTION
sd_journal_get_cursor() returns a cursor string for the current journal entry. A cursor is a serialization of the current journal position formatted as text. The string only contains printable characters and can be passed around in text form. The cursor identifies a journal entry globally and in a stable way and may be used to later seek to it via sd_journal_seek_cursor(3). The cursor string should be considered opaque and not be parsed by clients. Seeking to a cursor position without the specific entry being available locally will seek to the next closest (in terms of time) available entry. The call takes two arguments: a journal context object and a pointer to a string pointer where the cursor string will be placed. The string is allocated via libc malloc(3) and should be freed after use with free(3). Note that sd_journal_get_cursor() will not work before sd_journal_next(3) (or related call) has been called at least once, in order to position the read pointer at a valid entry. sd_journal_test_cursor() may be used to check whether the current position in the journal matches the specified cursor. This is useful since cursor strings do not uniquely identify an entry: the same entry might be referred to by multiple different cursor strings, and hence string comparing cursors is not possible. Use this call to verify after an invocation of sd_journal_seek_cursor(3) whether the entry being sought to was actually found in the journal or the next closest entry was used instead. RETURN VALUE
sd_journal_get_cursor() returns 0 on success or a negative errno-style error code. sd_journal_test_cursor() returns positive if the current entry matches the specified cursor, 0 if it does not match the specified cursor or a negative errno-style error code on failure. NOTES
The sd_journal_get_cursor() and sd_journal_test_cursor() interfaces are available as a shared library, which can be compiled and linked to with the libsystemd-journal pkg-config(1) file. SEE ALSO
systemd(1), sd-journal(3), sd_journal_open(3), sd_journal_seek_cursor(3) systemd 208 SD_JOURNAL_GET_CURSOR(3)
All times are GMT -4. The time now is 11:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy