LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Replace files via ssh (https://www.linuxquestions.org/questions/linux-newbie-8/replace-files-via-ssh-4175510154/)

spawn303 07-04-2014 05:10 PM

Replace files via ssh
 
Hello there.

Today we installed a test server with ubuntu.
we have a medical system running that holds test data.

We want to schedule a tast clearing the test data.
so far we managed to create a cron job, but we have trouble figure out
the command for overwriting the data.

that the test data is located in many different foldes we need to use a command the takes all sub dirs on the disk

we tried :

cp -Rf newdata.001 *.gmf

"newdata.001" is our fresh data file and *.gmf is the old test files.
how can we solve this?

lleb 07-04-2014 05:30 PM

are you trying to move the data from server A to server B?

If so then I encourage you to look up rsync as that is exactly what it is for.

if you are just trying to remove data from server B at set times you can create a simple script that scrubs those directories and sub directories as long as they are doing to be the same name.

instead of cp, you might want to try mv.

spawn303 07-04-2014 07:33 PM

no not at all

We like to replace (overwrite) all *.gmf with the newdata.001 file

btmiller 07-04-2014 07:50 PM

Maybe sometime like the following:

Code:

find $datadir -name "*.gmf" -exec cp /path/to/newdata.001 {} \;
replace $datadir with the absolute path to the directory with the gmf files and /path/to/newdata.001 with the actual path to the new data file.

Also, I'm trying not to sound rude here, but if you plan to be developing or deploying a medical records system on Linux, you really ought to have someone (be it in house or an outside consultant) that understands the platform. At least here in the USA there are all sorts of regulations like HIPPAA for systems like these, and while it doesn't matter much in a test environment with fake data, it will matter if these systems are deployed with real patient data on them. Security considerations and back-ups become highly important. Somebody on the team needs to understand these requirements and have enough Linux skills to ensure that they're met.

GaWdLy 07-05-2014 02:59 AM

^^This^^

Also, you can't replace *.xyz files with *.123 files. Won't work.

It would be easiest to run 2 seperate commands...

rm -rf *.xyz
cp -rf newfile.001

lleb 07-05-2014 12:19 PM

Quote:

Originally Posted by GaWdLy (Post 5198951)
^^This^^

Also, you can't replace *.xyz files with *.123 files. Won't work.

It would be easiest to run 2 seperate commands...

rm -rf *.xyz
cp -rf newfile.001

sure ya can, there is no reason to remove the file first before you copy over the newer data. that is 2x the work load on the CPU and not required. a simple cp or mv will do the trick.

spawn303 07-05-2014 07:58 PM

Ok guys thanks for the answers.

I think from this new knowledge I can refrase my question.

The case is that the *.gmf files just needs to be overwriten with a zerobyte file (witch we created as a "newdata.001" file)

1. we can not remove (delete) all *.gmf files that they are placed in different datafolders with specific names that the system depends on.

So my question is, can I somehow make all gmf files on the entire disk written as zerobyte files (clear the files)

I was searching on google and found out that maybe the files could be truncated, could this work :

> *.gmf

schneidz 07-05-2014 09:19 PM

still not really understanding. maybe something like:
Code:

find /whatever/floats/your/boat -type f -name "*.gmf" -exec echo > '{}' \;
maybe you can get better specific advice if you mention the medical system or what you are attempting to achieve ?

lleb 07-06-2014 10:11 PM

ok after a fast google search, it appears the .gmf file extension is some kind of image from some special software. in that case a mv would most likely be best in combination with the find command.

Code:

DOW=`date +%A`
mkdir ./${DOW}
find /path/to/graphic/files -type -f -name "*.gmf" -exec mv "{}" ./DOW \;

you might want to add some kind of check into that so you do not create a new directory over an old potentially destroying any data in the old directory. or you could just manually create the 7 folders and remove the mkdir from the above bit of code.


All times are GMT -5. The time now is 08:47 AM.