2

I am using script command to record everything from terminal. But when I am opening the generated file its having lots of junk character. Can anyone help me to remove these junk characters from file or any other alternate way?

This file look like this:

ossvm10(0)> ls -lrt /usr/opt/temip/mmexe/mcc_fcl_pm.exe^M
^[[00m-rwxr-xr-x 1 root root 387517 Feb 18  2013 ^[[00;32m/usr/opt/temip/mmexe/mcc_fcl_pm.exe^[[00m^M
^[[m^[]0;temip@ossvm10:/home/dharmc^G[/home/dharmc]^M
ossvm10(0)> script -a unit_testing_TEMIPTFRLIN_00202_CR#9961.txtsum /usr/opt/temip/mmexe/mcc_fcl_pm.exe^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^[[1P^H^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^H^[[1P^[[1P^H^G^G^G^G^G^G^G^G^M
06046   379^M
^[]0;temip@ossvm10:/home/dharmc^G[/home/dharmc]^M
dcds
  • 982

1 Answers1

1

You can simply run:

dos2unix <filename>

This will remove all the ^M characters from the file. ^M is the carriage-return character generated in a DOS environment. The command dos2unix just converts the file from DOS to Unix format.

To remove the ^H and ^G characters, use sed:

sed -i 's/\^H//g;s/\^G//g' <filename>

Sreeraj
  • 5,062