Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am currently backing up my system. If I use
> tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found--exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
It says the system doesn't have enought space.
Right now, I have mount a usb in directory
~/mnt/sdc1
How do I tar the backup.tgz to this specific location?
You will want to do two things. First insure that your drive is mounted, Then just provide the complete path to your backup location. E.g.
mount | grep -q ~/mnt/sdc1 # or just grep -q sdc1 (if it is the only sdc1)
if [ $? -eq 0 ]; then
tar cvpzf ~/mnt/sdc1/backup.tgz ...
fi
note: the replace the ellipses with the rest of your tar command.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
There was a directory structure on my linux server like this A/$b/
From my home directory executed a command
rm -rf A/$b.
After executing this command, The directory A itself was deleted.
Any idea what would have happened in the background?
A $ sign indicates the start of a variable in most shell languages.
If $b is not defined then your command would resolve as:
rm -rf A/
… which would delete the A directory.
To include the $ in the path you need to escape it:
rm -rf A/\$B
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I want to move/copy a file from the Documents directory into /etc/bind I tried:
sudo mv ~/Documents/Config_Files/db.example.lan /path/to/etc/bind/
I also tried:
sudo mv ~/Documents/Config_Files/db.example.lan /path/to/~//etc/bind/
But also got the error: "No such file or directory"
I am probably being dumb but I double checked spelling capitilisation and everything is correct but still won't come up as a directory.
I can't guide you much but, as you can see we use 'sudo mv' and this means we tell root to move it and you type '~' which means home directory...
So if you type:
sudo mv ~/Documents
this means
sudo mv /root/Documents
instead of
sudo mv /home/<xyz>/Documents
Try to give proper path and let me know if it works.!
example:
sudo mv /home/<username>/Documents/Config_Files/db.example.lan /etc/bind/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have multiple tar's that I want to untar into a folder and then append a prefix to them. The problem is that I don't know the name of the folder that it would create on the target system since these are build tar's and they have a date-timestamp inside. Here is what I tried -
tar xfz <filename>-*.tar.gz -C $UNTAR_LOCATION
so this creates a folder like this 20140909-0900 on the target UNTAR_LOCATION. How can I append a prefix to the date-timestamp ?
Note - there will be multiple folders with different date-timestamps under UNTAR_LOCATION for which I want to add the same prefix.
With versions of tar that support the --transform flag you should be able to use something like this:
tar -xzf <filename>-*.tar.gz -C "$untar_location" --transform='s,^,prefix,'
Here's how to do it with pax, the portable archiver:
gzip -cd filename.tar.gz | ( cd "$untar_location" && pax -r -s,^,prefix-, )
Most implementations of pax also has a -z option to filter through gzip, in which case it becomes
( cd "$untar_location" && pax -zrf filename.tar.gz -s,^,prefix-, )
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
What I'm doing is:
tar -czf etc.tar.gz /etc /usr/local/etc
And when I extract it I will have two directories:
1) etc
2) usr
What I want is to do it this way that I will have only etc after extracting with contents of this two directories.
Thanks.
Is there any other way than creating temporary directory with merged files from /etc and /usr/local/etc and then removing it?
cd /
tar -cf /path/to/etc.tar etc/
cd /usr/local
tar -rf /path/to/etc.tar etc/
cd /path/to
gzip etc.tar
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
Is there a way to copy local files with curl, I need it to work as an alternative for cp command.
This is a bit strange, but I'm working on an environment where cp is not available.
You could say:
curl -o /path/to/destination file:///path/to/source/file
This would copy /path/to/source/file to /path/to/destination.
you can use rsync
rsync -avz /path/to/src/file /path/to/dst/dir
You can also use tar
cd /path/to/src/dir; tar -cpf - sourcefile | (cd /path/to/dest/dir; tar -xpf -)
if your tar support -C
cd /path/to/src/dir; tar -cpf - sourcefile | tar -xpf - -C /path/to/dest/dir