Shift record from one position to another

Hi All,

I have a file and it is a fixed length file. I want to move the values from 42,6 ( where 6 is length) to the 36th position

Original file:
00000100000100000100000100000100001      000870                                                                  
00001000001000001000001000001000001      000879                                                                                  
09000001000001000001000001000001001      001818                                                             
29000020900000100000100000100000001      001816                                           
29000020900000100000100000100000001      001817
Expected : 
00000100000100000100000100000100001000870                                                                  
00001000001000001000001000001000001000879                                                                                  
09000001000001000001000001000001001001818                                                             
29000020900000100000100000100000001001816                                           
29000020900000100000100000100000001001817  

Things I have tried.
I am doing a cut on 42,6 and storing it in temp file then doing cut on 1,36 and the merging the file. Not working

cut -c1-36 file1
cut c46-52  file2

join file1 file2 > file3 -- not giving right result
Paste -s  file1 file2 -- giving me all result in one line formate
cat file1 file2 --->appending the file at end

Thanks in advance

Try this

sed 's/      //g' file1 > output.file

--- Post updated at 05:47 AM ---

Try below :-

sed 's/      //g' file1 > output.file
tr -d ' ' <file1 > output.file

Thanks for the input . I should have been more clear. This sed will convert all blank space to non blank. There is a change that other position can be blank. I need to move these only based on position

cut

cut -c1-35,42- data.txt

sed

sed -re 's/(.{35}).{6}/\1/' data.txt

Perl

perl -pe 's/^(.{35}).{6}/$1/' data.txt

GNU(!) awk

awk 'match($0,/^(.{35}).{6}(.*)/,res){print res[1] res[2]}' data.txt
4 Likes