Languages
[Edit]
EN

Bash - redirect command outputs to file

0 points
Created by:
marc_so
1014

This article will show you how to redirect command outputs to file in Bash.

Quick solution:

command &> output.txt

Note:

If you want data to be added to an existing file use >> instead of >.

 

Practical examples

my_script.sh

#!/bin/bash

echo "text from the script"

 Redirect the command output to the output.txt file by:

$ ./my_script.sh &> output.txt

output.txt

text from the script
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - redirect command outputs to file
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join