Bash (Unix shell): Difference between revisions

Line 68: Line 68:
}
}
say_hello World
say_hello World
</syntaxhighlight>
===Redirects===
[https://www.gnu.org/software/bash/manual/html_node/Redirections.html Redirections]
<syntaxhighlight lang="bash">
# `ls` is an example command
# Input to stdin
ls < word
# Output stdout to file
ls > file.txt
# Append stdout to file
ls >> file.txt
# Output stderr and stdout to file
ls > file.txt 2>&1
ls &> file.txt # Only works in bash, not sh
</syntaxhighlight>
</syntaxhighlight>