tar -cjf site1.tar.bz2 -C /var/www/site1 .
In the above example, tar will change to directory /var/www/site1
before doing its thing because the option -C /var/www/site1
was given.
From man tar
:
OTHER OPTIONS
-C, --directory DIR
change to directory DIR
More Related Contents:
- Find files and tar them (with spaces)
- sh: 1: Syntax error: "(" unexpected error
- Use Expect in a Bash script to provide a password to an SSH command
- How do I write standard error to a file while using “tee” with a pipe?
- How to declare 2D array in bash
- What does $@ mean in a shell script?
- Raise error in a Bash script
- Separately redirecting and recombining stderr/stdout without losing ordering
- Print a file, skipping the first X lines, in Bash [duplicate]
- How can I get unique values from an array in Bash?
- Managing log files created by cron jobs
- How to run a shell script on a Unix console or Mac terminal?
- How to get the process ID to kill a nohup process?
- equivalent date from GNU to solaris
- Use sudo without password INSIDE a script
- Execute a command without keeping it in history [closed]
- In bash, how to store a return value in a variable?
- The Bash command :(){ :|:& };: will spawn processes to kernel death. Can you explain the syntax?
- How do I run multiple background commands in bash in a single line?
- Add a newline only if it doesn’t exist
- Multithreading in Bash [duplicate]
- Simple Socket Server in Bash?
- Difference between shell and environment variables
- How to automatically add user account AND password with a Bash script?
- Meaning of tilde in Linux bash (not home directory)
- How do I delete all lines in a file starting from after a matching line?
- How to convert hex to ASCII characters in the Linux shell?
- How to check if a program is run in Bash on Ubuntu on Windows and not just plain Ubuntu?
- What are the rules for valid identifiers (e.g. functions, vars, etc) in Bash?
- Bash `wait` command, waiting for more than 1 PID to finish execution