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
I am trying to do an scp (on SuSE LINUX) and seeing something that I did not expect.
scp -q -r /home/dir1/mydir host:/var/home/dirx/BACKUPS
If there is /var/home/dirx/BACKUPS/mydir under the destination host, I see that the existing directories under that directory (including modification times) are left untouched. Only new directories are created.
If there are files in the destination directory that do not exist in the source directory, they are preserved.
After the copy, I was expecting to see the destination directory as an exact copy of the source directory. Seems like more of a merge.
Is that how scp supposed to work?
That's standard behavior for a copy command in pretty much any system. Files which exist in both locations will cause the destination to get refreshed with a source copy. Files which don't exist in the destination will be created/copied from the source.
Files which exist ONLY in the destination will not be affected, because it's not copy/cp's job to delete "stale" files - it has no way of knowing what a stale file is.
If you want to remove old/obsolete files in the destination, you'll need some other tool.
The other tool is ssh combined with tar. This will do the trick if you want to completely scrap the target directory and recreate it.
( cd /home/dir1/mydir && tar cf - . ) | ssh host "cd /var/home/dirx && rm -rf BACKUPS && mkdir BACKUPS && cd BACKUPS && tar xvf -"
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 2 years ago.
Improve this question
I am downloading many files from a password-protected server. They suggested using:
wget -i urllist.txt --user name --ask-password
to download files. I am able to download files but the problem is I want to change all files with each step of running this script so that I will have the correct files name.
For a single file download -output option was working but for many files, I am having a problem. Can you help me out?
I am not sure what you mean with:
I want to change all files with each step of running this script so
that I will have the correct files name.
How about if you download all files to a folder and later rename they way you want?
wget manuals says:
-P prefix
--directory-prefix=prefix Set directory prefix to prefix. The directory prefix is the directory where all other files and
subdirectories will be saved to, i.e. the top of the retrieval tree.
The default is . (the current directory).
Therefore you could use:
wget -P download-folder -i urllist.txt --user name --ask-password
Now you call manually rename the files in download-folder.
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.
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
Operating system: SLES12 VM
So I start off in a directory:
DirA: /home/user/testA/testB
My goal is to move a file from this directory to a directory given by
DirB_rel: /home/user/testA/testB/../../deliverables/rpm/SOURCE
Note: testA is a symlink which is not included in DirB_abs
Which, when I cd to it, gives a pwd of
DirB_abs:/home/user/deliverables/rpm/SOURCE
The problem is, when I try move a file using mv (have tried tar.gz and .txt) from DirA to DirB_rel, the file is deleted from original location as expected, but it does not appear at new location and is therefore lost.
E.g. mv testFile.txt DirB_rel -> File disappears
However, when I use the absolute path for directory B, mv works correctly.
E.g. mv testFile.txt DirB_abs -> Success
Any idea whats going on here?
Thanks!
The problem is with the symlink. When you do user/testA/testB/../../ and testA is asymlink, you wont go back to user, but to the parent directory of the directory testA links to
the mv command will reference the directory you are currently in and not from where the file is. So if we are in home ~/ and want to move ~/A/file to ~/B/file you use mv as follows:
mv A/file B/
Note that if you use this
mv A/file ../B/
the command will look for B in /home/B and not ~/B since we are in the ~/ directory issuing the command.
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 8 years ago.
Improve this question
I have a directory /f/ssh which I would like to turn into /f/.ssh. I'm working with git-bash on win7 I've tried:
/f
$ mv /ssh /.ssh
mv: cannot stat `/ssh': No such file or directory
/f
$ mv ssh .ssh
mv: cannot move `ssh' to `.ssh/ssh'
But its not working. How can I make this happen ?
You probably want your second example (current working directory) and not root (/).
$ mv ssh .ssh
mv: cannot move `ssh' to `.ssh/ssh'
What this is saying is there is already a folder called ".ssh" in your current working directory.
By calling that command again it's also saying you don't have access to move "ssh" into the already existing ".ssh" folder.
Try an ls -al to list all current files/folders in the directory, including hidden.