0

I am trying to record a reoccurring test to a txt file using tail but there is an issue with the output.

The commands I am running are:

script -q /dev/stdout -c 'scp /home/user/test.img user@pc28:/tmp' | tee /home/user/scp.log
tail -3 /home/user/scp.log >> /home/user/test.txt

The issue is the text looks like--

^Mtest.img                                                                                                                                                                           
0%    0     0.0KB/s   --:-- ETA^Mtest.img                                                                                                                                                                          
16%   82MB  81.7MB/s   00:05 ETA^Mtest.img                                                                                                                                                                          
35%  178MB  83.2MB/s   00:03 ETA^Mtest.img                                                                                                                                                                          
51%  256MB  82.7MB/s   00:02 ETA^Mtest.img                                                                                                                                                             
65%  328MB  81.6MB/s   00:02 ETA^Mtest.img                                                                                                                                                                          
84%  421MB  82.8MB/s   00:00 ETA^Mtest.img                                                                                                                                                         
100%  500MB  87.0MB/s   00:05`

instead of

*test.img 
100%  500MB  87.0MB/s   00:05*

which is what it looks like if i cat the file. I see the long messy output if i less or vi the file.

6
  • 3
    This is because you are looking at the standard error output, the progress reports which all end with \r instead of \n. What output do you actually want? What are you expecting here?
    – terdon
    May 12 at 19:18
  • Why are you using script at all here?
    – roaima
    May 12 at 22:32
  • @roaima my goal is to run scp from a bash script and i can't record the progress/speed unless i use script
    – noob
    May 12 at 23:27
  • @terdon I want my output to ideally just show the 100% line instead of each step of progress (0% 16% 35% etc)
    – noob
    May 12 at 23:29
  • "i can't record the progress/speed unless i use script" if it's a noninteractive script there's no point recording progress. Just capture the speed and duration
    – roaima
    May 12 at 23:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.