| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
sed -r 's|^| |;s|.*(.....$)|\1|'
add spaces to the beginning of line, as many as the maximum line width
cut from the end of the line the amount of chars of the line width
On 14/11/15 19:19, Daniel Goldman [email protected] [sed-users] wrote:
> I double-checked my sent folder, and a copy sent to myself. Actually, I
> did post sensibly, but yahoo did not transmit sensibly. Unfortunately,
> yahoo stripped out leading blanks from the lines, so yes it ended up
> input.x = output.x :( So so thanks for asking.
>
> Please look at the following, and imagine that the colons are not there,
> and that's how I posted. In this case, each line has five characters,
> but it could be a different number of characters.
>
> $ cat input.x
> :99 :
> : 99:
> : 9 :
> : 9 9 :
> :99999:
>
> $ cat output.x
> : 99:
> : 99:
> : 9:
> : 9 9:
> :99999:
>
> In case yahoo mangles the above, here is another way to display it,
> where you would please imagine that each '-' is a blank.
>
> $ cat input.x
> 99---
> ---99
> -9---
> -9-9-
> 99999
>
> $ cat output.x
> ---99
> ---99
> ----9
> --9-9
> 99999
>
> Thanks,
> Daniel
>
> On 11/14/2015 9:36 AM, Rakesh Sharma [email protected] [sed-users]
> wrote:
>> Your input.x = output.x and also what do you mean each line in input.x has the same length? look at the line 99999.
>>
>> You need to post sensibly first.
>>
>>
>> ________________________________
>> From: [email protected] <[email protected]> on behalf of Daniel Goldman [email protected] [sed-users] <[email protected]>
>> Sent: Saturday, November 14, 2015 9:25 AM
>> To: [email protected]
>> Subject: right justify each line?
>>
>>
>>
>> Hi,
>>
>> Assume each line in input.x has the same length.
>>
>> $ cat input.x
>> 99
>> 99
>> 9
>> 9 9
>> 99999
>>
>> I want to right justify each line, so output.x would be:
>>
>> $ cat output.x
>> 99
>> 99
>> 9
>> 9 9
>> 99999
>>
>> What is simplest way to convert input.x to output.x?
>>
>> I tried the following, but does not work, because of greedy evaluation,
>> \2 always encompasses the entire line.
>>
>> $ sed "s/^\(.*\)\( *\)$/\2\1/" input.x
>>
>> Thanks,
>> Daniel
>>
>>
>>
>>
>> [Non-text portions of this message have been removed]
>>
>>
>>
>> ------------------------------------
>> Posted by: Rakesh Sharma <[email protected]>
>> ------------------------------------
>>
>
> ------------------------------------
> Posted by: Daniel Goldman <[email protected]>
> ------------------------------------
>
------------------------------------
------------------------------------
--
------------------------------------
Yahoo Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/sed-users/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/