Sponsored Content
Top Forums Shell Programming and Scripting awk sed to repeat every character on same position from the upper line replacing whitespace Post 303006348 by nakaedu on Tuesday 31st of October 2017 05:20:00 PM
Old 10-31-2017
Code:
awk -F'[^ ]' '
{	current_len = length($1)
	last_len = length(last_line)
	len = current_len > last_len ? last_len : current_len
	last_line = substr(last_line, 1, len) substr($0, len + 1)
	print last_line
}' file

Thanks a lot, it worked perfectly.
I saved it as an awk file as I am on Windows to avoid the conversion/adaptation and I am launching as a .awk file and it works perfectly

Last edited by Don Cragun; 10-31-2017 at 07:12 PM.. Reason: Change QUOTE tags to CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

error while replacing a string by new line character in sed

hi, when i am doing the following things getting error Can anyone please suggest i have a file where there is a line like the following branch=dev sdf dev jin kilii fin kale boyle dev james dev i want to search the existance of dev in the above line. cat "$file" | sed -n... (8 Replies)
Discussion started by: millan
8 Replies

2. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

3. Shell Programming and Scripting

Remove text from n position to n position sed/awk

I want to remove text from nth position to nth position couple of times in same line my line is "hello is there anyone can help me with this question" I need like this ello is there anyone can help me with question 'h' is removed and 'this' removed from the line. I want to do this... (5 Replies)
Discussion started by: elamurugu
5 Replies

4. Shell Programming and Scripting

Delete character in determinate position with sed/awk

Hello. I'm trying to delete one character in determinate position. Example: qwEtsdf123Ecv34 <delete character in positión 3> Result: qwtsdf123Ecv34 Plase, help me. Thanks (4 Replies)
Discussion started by: maria_florencia
4 Replies

5. Shell Programming and Scripting

position of character in a line

i want to find the position of a character in a line , the first position, last, 5th occurence position , i ve tried grep -n , and expr index but they dont fit the bill. Please let me know if there is any other alternative (2 Replies)
Discussion started by: phpsnook
2 Replies

6. Shell Programming and Scripting

sed or awk delete character in the lines before and after the matching line

Sample file: This is line one, this is another line, this is the PRIMARY INDEX line l ; This is another line The command should find the line with “PRIMARY INDEX” and remove the last character from the line preceding it (in this case , comma) and remove the first character from the line... (5 Replies)
Discussion started by: KC_Rules
5 Replies

7. Shell Programming and Scripting

Repeat line convert upper line

HI Guys, My Input :- R3 AV44 50 0 100 100 100 R3 AV44 1 0 100 100 100 R3 AV45 50 0 100 100 100 R3 AV45 0 3 100 100 100 R3 AV45S 50 0 100 100 100 R3 AV45S 0 4 100 100 100 Output :- R3 AV44 50 0 100 100 100 1 0 100 100 100 R3 AV45 50 0 100 100 100 0 3 100 100 100 R3 AV45S 50 0... (9 Replies)
Discussion started by: pareshkp
9 Replies

8. Shell Programming and Scripting

Replacing lines matching a multi-line pattern (sed/perl/awk)

Dear Unix Forums, I am hoping you can help me with a pattern matching problem. What am I trying to do? I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
Discussion started by: thefang
10 Replies

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

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
xcb_randr_get_crtc_transform(3) 				   XCB Requests 				   xcb_randr_get_crtc_transform(3)

NAME
xcb_randr_get_crtc_transform - SYNOPSIS
#include <xcb/randr.h> Request function xcb_randr_get_crtc_transform_cookie_t xcb_randr_get_crtc_transform(xcb_connection_t *conn, xcb_randr_crtc_t crtc); Reply datastructure typedef struct xcb_randr_get_crtc_transform_reply_t { uint8_t response_type; uint8_t pad0; uint16_t sequence; uint32_t length; xcb_render_transform_t pending_transform; uint8_t has_transforms; uint8_t pad1[3]; xcb_render_transform_t current_transform; uint8_t pad2[4]; uint16_t pending_len; uint16_t pending_nparams; uint16_t current_len; uint16_t current_nparams; } xcb_randr_get_crtc_transform_reply_t; Reply function xcb_randr_get_crtc_transform_reply_t *xcb_randr_get_crtc_transform_reply(xcb_connection_t *conn, xcb_randr_get_crtc_transform_cookie_t cookie, xcb_generic_error_t **e); Reply accessors char *xcb_randr_get_crtc_transform_pending_filter_name(const xcb_randr_get_crtc_transform_request_t *reply); int xcb_randr_get_crtc_transform_pending_filter_name_length(const xcb_randr_get_crtc_transform_reply_t *reply); xcb_generic_iterator_t xcb_randr_get_crtc_transform_pending_filter_name_end(const xcb_randr_get_crtc_transform_reply_t *reply); xcb_render_fixed_t *xcb_randr_get_crtc_transform_pending_params(const xcb_randr_get_crtc_transform_request_t *reply); int xcb_randr_get_crtc_transform_pending_params_length(const xcb_randr_get_crtc_transform_reply_t *reply); xcb_generic_iterator_t xcb_randr_get_crtc_transform_pending_params_end(const xcb_randr_get_crtc_transform_reply_t *reply); char *xcb_randr_get_crtc_transform_current_filter_name(const xcb_randr_get_crtc_transform_request_t *reply); int xcb_randr_get_crtc_transform_current_filter_name_length(const xcb_randr_get_crtc_transform_reply_t *reply); xcb_generic_iterator_t xcb_randr_get_crtc_transform_current_filter_name_end(const xcb_randr_get_crtc_transform_reply_t *reply); xcb_render_fixed_t *xcb_randr_get_crtc_transform_current_params(const xcb_randr_get_crtc_transform_request_t *reply); int xcb_randr_get_crtc_transform_current_params_length(const xcb_randr_get_crtc_transform_reply_t *reply); xcb_generic_iterator_t xcb_randr_get_crtc_transform_current_params_end(const xcb_randr_get_crtc_transform_reply_t *reply); REQUEST ARGUMENTS
conn The XCB connection to X11. crtc TODO: NOT YET DOCUMENTED. REPLY FIELDS
response_type The type of this reply, in this case XCB_RANDR_GET_CRTC_TRANSFORM. This field is also present in the xcb_generic_reply_t and can be used to tell replies apart from each other. sequence The sequence number of the last request processed by the X11 server. length The length of the reply, in words (a word is 4 bytes). pending_transform TODO: NOT YET DOCUMENTED. has_transforms TODO: NOT YET DOCUMENTED. current_transform TODO: NOT YET DOCUMENTED. pending_len TODO: NOT YET DOCUMENTED. pending_nparams TODO: NOT YET DOCUMENTED. current_len TODO: NOT YET DOCUMENTED. current_nparams TODO: NOT YET DOCUMENTED. DESCRIPTION
RETURN VALUE
Returns an xcb_randr_get_crtc_transform_cookie_t. Errors have to be handled when calling the reply function xcb_randr_get_crtc_trans- form_reply. If you want to handle errors in the event loop instead, use xcb_randr_get_crtc_transform_unchecked. See xcb-requests(3) for details. ERRORS
This request does never generate any errors. SEE ALSO
AUTHOR
Generated from randr.xml. Contact xcb@lists.freedesktop.org for corrections and improvements. XCB
2014-06-10 xcb_randr_get_crtc_transform(3)
All times are GMT -4. The time now is 02:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy