Re: right justify each line?

"Daniel Goldman [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
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]>
> ------------------------------------
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.