Linux CentOS rename files for every directory with known structure - linux

I have lots of directories with the same structure. A specific folder in a directory can contain a file, that I want to rename.
mv /home/*?*/domains/*?*/public/old.text /home/*?*/domains/*?*/public/new.txt
The ? can be different each time.
I tried the above, but didn't work of course.
It's on a Linux CentOS machine.

Does this do what you want?
for i in /home/*/domains/*/public/; do
echo mv "$i/old.txt" "$i/new.txt"
done

Related

How to move all files to subdirectories by extension name in the specified DIR directory?

How to move all files (except directories) to subdirectories by extension name in the specified DIR directory?
If I'm understanding your question correctly, globbing should help you. If you're going to be using linux for a while, I'd recommend reading up on it, as it makes using linux and bash much easier.
To directly answer your question, something like this should work:
mv *.<extension> <target directory>

Copying multiple files knowing their directories

I have multiple files' directories and i need to copy them into specific folder using terminal, how do i do it. I also have access to GUI of the system, as all this is being done in virtual machine using ssh
According to its manpage, cp is capable of copying various source files to one output directory.
The syntax is as follows:
cp /dir1/file1 /dir1/file2 /dir2/file1_2 /outputdir/
Using this command, you can copy files from multiple directories (/dir1/ and /dir2/ in this example) to one output directory (/outputdir/).

I am trying to copy entire directories from one Linux machine to another, including permissions

I am trying to copy entire directories from one Linux machine to another, including permissions, and including the called directory. For example,
from the parent directory of the destination, I tried
rsync -rul root#mail3.domain.com/usr/sites/4my.com
but that does not work.
On the calling machine the destination is /home/sites
What should that command be?
Thanks!
try rsync -a username#remote_host:/home/username/dir1 place_to_sync_on_local_machine
Try
sudo cp -rp /home/source /tmp/dest

is it possible to put comments in a directory about a dir or file?

is it possible to put comments in a directory about a dir or file locally on my own machine, appearing in my terminal. I don't have any kind of GUI, so this would be helpful.
Maybe something like, when I do ls -l I will see:
file.txt #this is that file I made on tuesday
files #this is the directory I made with all those other files
If so, what is the tool to do it?
Is it available for Arch Linux?
Yes, there is a tool for that. It is called GIT or SVN.

Copy all files on cron run - regular task

I've got a virtual dedicated server (running FreeBSD 6.x) and I need to regulary backup files from one folder to another, say from /home/LOGIN/data/www/mydomain.com/test1 to /home/LOGIN/data/www/mydomain.com/test2. I've tried different approaches:
rsync -a /home/LOGIN/data/www/mydomain.com/test1 /home/LOGIN/data/www/mydomain.com/test2
cp /home/LOGIN/data/www/mydomain.com/test1 /home/LOGIN/data/www/mydomain.com/test2
cp www/mydomain.com/test1 /www/mydomain.com/test2
but all this didn't work, it gave error #127 and others.
AFAIK this can be done using a php script to run by cron also.
what is the better way?
try
cp /home/LOGIN/data/www/mydomain.com/test1/*
/home/LOGON/data/www/mydomain.com/test2
and make sure the test2 directory is existent

Resources