Use >>
instead of >
when directing output to a file:
your_command >> file_to_append_to
If file_to_append_to
does not exist, it will be created.
Example:
$ echo "hello" > file
$ echo "world" >> file
$ cat file
hello
world
More Related Contents:
- Expansion of variables inside single quotes in a command in Bash
- Reading quoted/escaped arguments correctly from a string
- Can a shell script set environment variables of the calling shell? [duplicate]
- How to add a progress bar to a shell script?
- What is the purpose of “&&” in a shell command?
- How can I remove the extension of a filename in a shell script?
- sudo echo “something” >> /etc/privilegedFile doesn’t work [duplicate]
- Convert absolute path into relative path given a current directory using Bash
- While-loop subshell dilemma in Bash
- How do I escape the wildcard/asterisk character in bash?
- Check existence of input argument in a Bash shell script
- YYYY-MM-DD format date in shell script
- How to suppress Terminated message after killing in bash?
- Get current directory name (without full path) in a Bash script
- How do I redirect output to a variable in shell? [duplicate]
- What do $? $0 $1 $2 mean in shell script? [duplicate]
- Division in script and floating-point
- Copy folder recursively, excluding some folders
- Variable interpolation in the shell
- How to remove filename prefix with a Posix shell
- How to pipe multiple commands into a single command in the shell? (sh, bash, …)
- What does ” 2>&1 ” mean?
- How do I read user input into a variable in Bash?
- Why do I get “/bin/sh: Argument list too long” when passing quoted arguments?
- How do I check if a directory exists or not in a Bash shell script?
- Validate date format in a shell script
- shell script respond to keypress
- How to update one file in a zip archive
- Why doesn’t my terminal output unicode characters properly?
- How to read variables from file, with multiple variables per line?