0

i use travis-ci to build linux from scratch version 7.8. during build, travis-ci throw error because log file large than 4 mega bytes. you can see at lfs-auto, build #15

now, i want to redirect all data from stdout to /dev/null to reduce size of log file. in normal way, people use redirect operation for each command as dev/null. but that way make shell script become too long and hard to read

any body have idea to solve that problems ?


problem are solved!. thank to every body has comments

i pick up solution exec > /dev/null because that command redirect all output from std to /dev/null without other operations. in this case, exec > /dev/null are simple, easy to edit than script-file > /dev/null or { command, ... } > /dev/null


solve question duplicate

with some comments, this question have content same as How do I redirect the output of an entire shell script within the script itself? and how to redirect output of multiple commands to one file

i am recognize that my question same as How do I redirect the output of an entire shell script within the script itself?, but my question are more clear, shorter

i need more comments to solve duplicate problems in two case

  • merge this question with other question and delete this question
  • delete this question and do nothing
  • do nothing
Kevin Leptons
  • 17
  • 1
  • 6
  • Is `./your-script > /dev/null` not short enough? Or I did not understand your question. – Rany Albeg Wein Apr 10 '16 at 14:44
  • See: [After using `exec 1>file`, how can I stop this redirection of the STDOUT to file and restore the normal operation of STDOUT?](http://stackoverflow.com/q/25474854/3776858). Insert in your script `exec >/dev/null`. – Cyrus Apr 10 '16 at 14:46
  • An alternative candidate for duplicate question is [How to redirect output of multiple commands to one file](https://stackoverflow.com/questions/20355264/); another is [How do I redirect the output of an entire shell script within the script itself?](https://stackoverflow.com/questions/314675/). There are probably others. There's no immediate need to change the duplicate chosen. – Jonathan Leffler Apr 10 '16 at 17:30

1 Answers1

1

Use Bash Command Grouping

While there's more than one way to achieve your goals, I'd suggest editing your build script to group commands. Wrapping a group of commands in curly brackets allows you to redirect all commands in the list to the same place. For example:

{
    echo foo
    echo bar
    echo baz
} > /dev/null

While not technically identical, from a pragmatic standpoint this will provide similar results to redirecting each command separately to /dev/null.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199