what is the difference between " > " and ">>" in linux i know it has to do with redirection but not sure what is exactly the difference
example: ls > a.txt ls >> a.txt
So, what we learned is, the “>” is the output redirection operator used for overwriting files that already exist in the directory. While, the “>>” is an output operator as well, but, it appends the data of an existing file. Often, both of these operators are used together to modify files in Linux.
The > sign is used for redirecting the output of a program to something other than stdout (standard output, which is the terminal by default). The >> appends to a file or creates the file if it doesn't exist.
The “>” is an output operator that overwrites the existing file, while “>>” is also an output operator but appends the data in an already existing file. Both operators are often used to modify the files in Linux.
$* Stores all the arguments that were entered on the command line ($1 $2 ...). "$@" Stores all the arguments that were entered on the command line, individually quoted ("$1" "$2" ...).
You'll find them on manual, https://www.gnu.org/software/bash/manual/html_node/Redirections.html.
Actualy, >
is for stdout redirection to file, which is rewrite entire file. >>
is for append stdout output to the last line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With