How to add spaces to test.dat file in unix??

Hi

I have a test.dat file in UNIX which has a data.I am informatica developer i get data in those files.I need to add 50 spaces to those data in test.dat file.I am new to unix So can any one help how can i do that.

I have some 2088 rows in that test.dat file.

Can anyone help me please its very urgent.

Thanks
Nagaraj

Do you want to add 50 spaces in the beginning of each lines???

at the end of each line and thanks for quick response.

sed -i 's/\(.*\)/\1          /g' test.dat

The above sed script will add 10 space characters at the end of each lines in test.dat file.
Likewise you can add 50 spaces

Will this add spaces to all the 2088 rows in the file or do i need to add for each row??

Ya. It will add spaces to all the 2088 rows(2088 lines in the test.dat file)

awk 'BEGIN {for (i=1;i<=50;i++) a=a " " } {print $0 a}' test.dat > output.dat

You don't need to capture and use a backreference in this case. An ampersand in the replacement text will do. Also, the g flag is redundant since the pattern matches the entire line it can only match once. And, in case the original poster has any probs, note that -i requires GNU SED.

sed -i 's/.*/&          /' test.dat

Apologies if this post seemed nitpicky; I'm simply trying to help.

Regards,
Alister

Try:

perl -i -lne 'print $_." "x50;' test.dat

View the file using below command to verify

cat -vet test.dat

with your perl command, I got below export:

$ cat -vet output1
00:00:12,137;7,0333333                                                  ^M$
00:00:22,672;7,15                                                  ^M$
00:00:20,097;7,016667                                                  ^M$

with my awk, I got below export:

$ cat -vet output2
00:00:12,137;7,0333333                                                   $
00:00:22,672;7,15                                                   $
00:00:20,097;7,016667                                                   $

Why your perl has ^M in the file?

My file has just this out put(using your data to explain)

00:00:12,137;7,0333333
00:00:22,672;7,15
00:00:20,097;7,016667

i need to put spaces after the line to use those values as null in informatica,

Use with the chomp.

perl -i.bak -lne 'chomp;print $_." "x50;' file