how to write on separate lines?

Hello friends,
I have a file "a.txt" its contents
-----------------
pid 4075 (caiopr) shmat(1929379932, 0x0000000000000000, 0) = 0x00000000ff030000 (errno 0) pid 4075 (caiopr) shmdt(0x00000000ff030000) = 144 (errno 0) pid 4075 (caiopr) shmctl(1929379932, IPC_RMID) pid 4205 (cau9cli.exe) shmget(13, 0, 438) = 1 (errno 0) pid 4205 (cau9cli.exe) shmat(1, 0x0000000000000000, 0) = 0x00000000fea90000 (errno 0) pid 4205 (cau9cli.exe) shmdt(0x00000000fea90000) = 144 (errno 0) pid 4205 (cau9cli.exe) shmget(13, 0, 438) = 1 (errno 0) pid 4205 (cau9cli.exe) shmat(1, 0x0000000000000000, 0) = 0x00000000fea90000 (errno 0) pid 4205 (cau9cli.exe) shmget(0, 539, 1974) = 1929379932 (errno 0) pid 4205 (cau9cli.exe) shmat(1929379932, 0x0000000000000000, 0) = 0x00000000fee90000 (errno 0) pid 4205 (cau9cli.exe) shmdt(0x00000000fee90000) = 144 (errno 0) pid 4205 (cau9cli.exe) shmdt(0x00000000fea90000) = 144 (errno 0)

I want to know a command/ script which will format this a.txt such that each line will start with pid, please let me know.

Thanks

Try:

perl -pe 's/pid/\npid/g'  infile
 sed 's/\bpid\b/\n&/g'  infile

or some awks:

awk 1 RS=" pid " ORS="\npid " infile