Let's say I have two flash memory devices 1GB capacity each. Let's also say each device contains one big file ~ 1GB size. Assuming, I have limited (64MB) RAM and no hard disk drive, what is the shortest way to swap this two files ?I mean: if file a is on device A and b is on device B, I want swap operation to place a on B and b on A.I know there is no exact linux tool to do that according to this discussion.I am interested in shortest way to achieve my goal. If that way will be too long, I probably will have to implement my own dedicated solution that will perform swap chunk by chunk, am I right ?
Swap (exchange) two big files in limited environment
files;utilities
As long as both drives are full, or almost full, I doubt there is a pretty solution. It should be possible to loop over dd commands though.Something like#This code is completely untested, #do NOT just copy paste and use it without proper testingwhile [[ $((i*chunkSize)) -lt fileSize ]]; do  dd skip=$i seek=$i bs=$chunkSize count=1 if=fileA of=tmpFileInMemory  dd skip=$i seek=$i bs=$chunkSize count=1 if=fileB of=FileA  dd skip=$i seek=$i bs=$chunkSize count=1 if=tmpFileInMemory of=fileBdoneSome checks are needed for when fileA and fileB have different sizes.