LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-04-2014, 06:10 PM   #1
spawn303
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Rep: Reputation: Disabled
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?
 
Old 07-04-2014, 06:30 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
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.
 
Old 07-04-2014, 08:33 PM   #3
spawn303
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
no not at all

We like to replace (overwrite) all *.gmf with the newdata.001 file
 
Old 07-04-2014, 08:50 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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.
 
1 members found this post helpful.
Old 07-05-2014, 03:59 AM   #5
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
^^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
 
Old 07-05-2014, 01:19 PM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Quote:
Originally Posted by GaWdLy View Post
^^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.
 
Old 07-05-2014, 08:58 PM   #7
spawn303
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 07-05-2014, 10:19 PM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
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 ?

Last edited by schneidz; 07-05-2014 at 10:25 PM.
 
Old 07-06-2014, 11:11 PM   #9
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH Command to do mass search and replace ryedaleblue Linux - General 18 04-16-2013 10:29 PM
In SSH, how to replace a full domain name with an alias zbinwu Linux - Newbie 7 04-23-2012 08:14 AM
[SOLVED] How to replace ssh-askpass with ssh-askpass-gnome? rrije Linux - Software 2 11-10-2010 05:26 AM
[SOLVED] Find and replace in multiple files in ssh whitelinux Linux - Server 1 07-03-2010 05:43 PM
can i replace nis/nfs with ssh boazg Linux - Networking 1 03-14-2006 07:26 AM


All times are GMT -5. The time now is 05:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration