Languages
[Edit]
EN

Bash - redirect command outputs to file

0 points
Created by:
marc_so
234

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

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