Skip to content
Snippets Groups Projects

Store the last "N" lines of the output of a program

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Fernando Silva Coira
    NLinesOutput.sh 153 B
    #!/bin/bash
    
    ./myprogram | tail -n N > log.txt
    
    #example
    #./program | tail -n  10 > log.txt (store the last 10 lines of the output in the file "log.txt")
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment