Tagged Questions
1
vote
2answers
89 views
Can one copy a relpath in one command?
I find myself doing this often enough that I wonder if there's a standard Unix way to do it:
% mkdir -p /TARGETDIR/relative/path/to
% cp ./relative/path/to/somefile /TARGETDIR/relative/path/to
In ...
2
votes
3answers
72 views
How to cp or rm files based on ownership / permission
After a problem with spam, I stopped postfix
postfix stop
and checked through the mailq manually to find hundreds of thousands of unsent spam.
The spam was sent from one of the sites hosted ...
4
votes
2answers
544 views
tar files from another directory without copying them
This should be very simple for experts in here.
I have a Linux account with user disk quota of only 6GB. There is some data-folder in /opt with about 3GB of data with when compressed comes up 1GB. ...
9
votes
6answers
309 views
How to copy every 4th file in a folder
I have a lot of files in a folder, named like 00802_Bla_Aquarium_XXXXX.jpg. Now I need to copy every 4th file to a subfolder, saying in selected/.
00802_Bla_Aquarium_00020.jpg <= this one
...
8
votes
3answers
364 views
Flattening a nested directory
This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1):
/dir1
/dir2
|
--- file1
|
--- file2
What is ...
1
vote
1answer
72 views
Will files created under source directory after running `cp` be copied?
Suppose I use cp to copy a directory to another place. If the process takes long, and I create a new file under the source directory, will it be copied, or it depends? Thanks!
4
votes
4answers
1k views
How to copy directories with preserving hardlinks?
How to move directories that have files in common from one to another partition ?
Let's assume we have partition mounted on /mnt/X with directories sharing files with hardlinks.
How to move such ...
3
votes
1answer
430 views
How to replace a symbolic link with a copy of a file it links to?
Having a (single, no batch filesystem processing needed) symlink, what a command line to use to replace it with a copy of the file it links to?
2
votes
2answers
2k views
How can I selectively copy files from one directory to another directory?
On Linux, how do I selectively copy most – but not all – files from a directory (dir1) to another directory (dir2)?
I do not want to copy *.c and *.txt files to dir2.
The cp man page ...
3
votes
3answers
290 views
Delete files in a directory which are also in another directory
I copied a directory using this:
cp -r dir/ ../../
without thinking and realized that it copied the contents of dir instead of actually dir to the above directory. Now I have a mess of files I need ...