Include specific file from exluding folder [closed] - linux

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 5 years ago.
Improve this question
I am using rsyn to copy a folder from source to desination
I am able to use exclude successfully
$ rsync -av --exclude='*/deploy/scb_pdm/*' --exclude='*/logs/*' $COPY_SRC_DIR $COPY_DEST_DIR
server-4.5.0/conf/wrapper.conf
server-4.5.0/deploy/
server-4.5.0/deploy/scb_pdm/
server-4.5.0/deploy/scb_pdm/director.properties
server-4.5.0/deploy/scb_pdm/ocollate_static.madconfig
server-4.5.0/lib/
server-4.5.0/lib/blue-marble-4.5.0.201511121524.jar
Now I am stuck, How can I exclude only
server-4.5.0/deploy/scb_pdm/ocollate_static.madconfig

I'll start with the generic usage of rsync to exclude the directory.
In order to achieve that you need to use --exclude flag.
rsync -arv --exclude cache/ your_src_dir/ your_dest_dir/
to your case, this will exclude the specific file that is ocollate_static.madconfig.
rsync -arv --exclude='*/deploy/scb_pdm/ocollate_static.madconfig*' --exclude='*/logs/*' $COPY_SRC_DIR $COPY_DEST_DIR
You can think of using another flag that is
--delete-excluded also delete excluded files from dest dirs
Another option, excluding multiple files and dirs at the same time.
$ rsync -avz --exclude your_file1.txt --exclude dir3/file4.txt source/ destination/
For detail information about using exclude in rsync.

Related

How do i delete directory's in Linux (without first deleting the files inside) [closed]

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 just gotten a Raspberry Pi for Christmas and I wanted to delete some built in programs because I wanted to make a Linux server for home use. So far I had to do this all the time using the terminal because to delete the files, you had to use root.
rm ./files/*
rmdir files
Is there any way I can use rmdir command when there are files in it?
rm -rf files will remove the files directory and all subdirectories and not prompt you with questions about file permissions.
Sure just recursive delete :)
rm -r files
In your terminal, change directories to the one in the hierarchy just above the directory in question. Then:
$mv ./dir_to_del/* .; rmdir ./dir_to_del
This will move all the files out of the directory you want to delete, and then delete the now-empty folder.

tar every subfolder named X in a bash file [closed]

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 a folder that contains many folders and my wordpresses sites.
At the same folder i need to catch up the "uploads" subfolder and tar it named by its site.
Can anyone help me out?
Does this do the trick?
find /var/www -name uploads -a -type d | awk -F '/' '{ system("tar -czvf "$3".tar "$0) }'
The find command lists all the directories named upload under /var/www.
That's piped to awk, which splits it using the slash and runs tar. The third field is used as the file name and the whole string as the target for the tar.
This works for me: tar -cvf thisstuff.tar */uploads/*

Linux untar with prefix [closed]

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-, )

On Linux, what is the correct way to completely empty a directory without deleting it? [closed]

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
Obvious solutions such as rm -rf directory/* will forget hidden files, for example. What is the correct way to do this?
My use case is the following: my directory is a subfolder of a root controlled directory, created by root and chowned to my user. If I delete it, I won't have the permissions to re-create it. However I want to make sure it's completely clean at the start of my process.
Try this :
find directory -mindepth 1 -delete
You can use:
shopt -s dotglob
rm -rf directory/*
This will delete hidden files also (starting with a dot).
Or else use find -delete:
cd directory
find . -delete
You can use
rm -rf /some/path/.* deletes all hidden files in that dir

tar two directories with the same name to one archived directory [closed]

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

Resources