how to replace . with 100 spaces

i have a file like::
$ cat space
asd
fghj
itkg

now i want to replace the next line with . and thn this . with the 100 spaces.

cat space | tr '\n' '.', it woked for me, to replce the new line to .

Now i want to replace this . with 100 spaces.

Thanks in advance.

I guess you mean "newline" and not "next line".
Why an additional step in between ? Why not replace newlines with 100 spaces directly ?

Again, why substitute by the "." first ?

tyler_durden

If directly we can do it, it will be great. Can you please send me the command.

Do you want to replace the last character with 100 spaces?

cat fichero | sed "s/$/`perl -e 'print \" \" x 100'`/"

Or using just Perl:

$
$ cat space
asd
fghj
itkg
$
$ perl -ne '$x = " "x10; s/\n/$x/g; print' space
asd          fghj          itkg          $
$
$

Replace 10 by 100 in the one-liner above.

tyler_durden

perl -e ' while (<>) { print $_ ," "x100;} ' filename

Here i hope no need to use "cat".

Thanks tyler_durden, it worked:)

Now there is one more issue, in some lines i have 10 charactes & in some there are 20chars.
no. of spaces should be 200 - number of character in a line.

if No. of chars are 20 thn there should be 180 spaces.

please help me on this also.

Thanks in advance

How about this awk alternative?

awk '{printf "%-*s", (100-length($0)),$0}' file

is there anything we can add to the above command so that all the comma's (,) will be replaced by space.

How about, instead of feeding us information one by one, you giving us all the requirements at once?