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? Commented May 12, 2022 at 19:18
  • Why are you using script at all here? Commented May 12, 2022 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 Commented May 12, 2022 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) Commented May 12, 2022 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 Commented May 12, 2022 at 23:33

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.