1
vote
2answers
575 views

cp and mv if the file named already exists

What happens when you give the following commands if the file named done already exists? $ cp to_do done $ mv to_do done
1
vote
2answers
112 views

moving files of certain formats from subdirectoris to directories with same folder names

I’ve got a weird situation. I have 100s of folders with flac and mp3 copies of the same tracks. I need to separate the mp3s from the flacs and put them into similarly named directories. for example: ...
1
vote
1answer
152 views

Copying wallpaper images into a single folder

In my ubuntu 12.04 set-up, there are lots of wallpaper images in the directory /usr/share/wallpapers. For example, one might be usr/share/wallpapers/Leafs_Labyrinth/contents/images/1600x1200.jpg ...
2
votes
2answers
142 views

Is there a --parents option for mv like for cp?

cp has a useful feature --parents that allows a file's directory structure to be copied to another directory: $ cp -v --parents source/directory/from target/ ‘source/directory/from’ -> ...
7
votes
3answers
444 views

cp or mv files to same directory they are already in when I am in another?

If I am in ~/blob and I have a file in ~/blob/a_long_directory_name/c/x.x I can type mv blob/a_long_directory_name/c/x.x blob/a_long_directory_name/even_more/y.y Is there any shortcut whereby I ...
3
votes
3answers
70 views

Can I forbid the creation of files with certain permissions?

I have a directory with a certain group ID, and I only want files with the same ID to be in that directory. So I set the SGID bit on that directory, so that everytime a file is created inside it, it ...
1
vote
1answer
61 views

How rename directories tree entry by entry

I have text file contain two columns: current directory name the new name of the last entry d_7154/d_7161/ 'Main Integration' ...
2
votes
1answer
356 views

Minimal command to make a copy of a file [duplicate]

I often find myself copy-pasting long path in order to create a copy of a file cp /path/to/file/file1 /path/to/file/file1.bkp Is there an alternative utility that will NOT require me to type the ...
4
votes
2answers
238 views

Copy files with deleting suffix in name

How can be done coping files that have some suffix at the end, into same dir with the smallest command possible: Example have directory containing files: cassandra.yml.example database.yml.example ...
12
votes
3answers
3k 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 ...
22
votes
3answers
9k views

Why unix mv program doesn't need -R (recursive) option for directories but cp does need it?

This is a kind of "wtf?" question, so I'm sorry if I will disturb someone's vision of how things should be or if I will just annoy you with the "stupid" question. I always get messed up when need to ...
1
vote
1answer
148 views

Move some files on every dir to a different dir [duplicate]

Possible Duplicate: How can I move files by type recursively from a directory and its sub-directories to another directory? I'm quite new to Linux and specially to the shell and all of its ...
1
vote
1answer
248 views

Switching source and destination (or undoing the mv, cp operation)

mv or cp commands both expect source and destination as arguments. In case you want to undo the change you made, or just change the source and destination you supplied before, what is the quickest ...
1
vote
2answers
4k views

Batch copying/moving files in unix?

Is there a way to batch copy/move files in unix? I thought it might be an option for cp/mv but I can't find any way to do it.
1
vote
1answer
358 views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
4
votes
3answers
3k views

How do I move some but not all files from one directory to another?

I need to move my files from one directory to other. But there is some issues. My file name pattern is like: apple.0, apple.<n>, n -> {0,1,2,3 ...~ } so mv apple.* will not work, because ...
2
votes
2answers
298 views

How to update a content management installation by overwriting existing files via ssh and shell?

I have installed a cms (modx) on a webserver running CentOS 5 and Apache 2.2. Now there is a new version and I would like to update it. The instructions in the modx-wiki suggest to overwrite the ...
4
votes
1answer
2k views

Batch copy and rename with regexp

I am wondering whether there is a way how to copy and rename a bunch of files without scripting. I have files with names like prefix_12345678901_12345678901_suffix.ext and I need to copy all of them ...