LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 11-19-2010, 11:51 AM   #1
danndp
Member
 
Registered: Nov 2010
Posts: 51

Rep: Reputation: 2
How to change a line in a rsync script and send the file changed


Hello my friends,

I'm configuring an rsync between 2 machines, A_Server --> B_Server, using the following script:

Code:
#!/bin/bash
#
# Script de backup a través de Rsync desde RMP-1 hasta RMP-2.
#
# Si se produce algún error en cualquier momento abortar.
#set -e

DATOS="/tmp/prueba.txt"
EXCLUDES=
OPTS="-vv --relative --delete --force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES -a"
RSERVER="rsync://A_Server@192.168.1.4/A_Server/"
export RSYNC_PASSWORD=1234

#Este script sincroniza los datos de Asterisk de RMP-1 a RMP-2 a través 
#del servicio rsyncd. Los datos se guardan en RMP-2 en la carpeta 
#/home/RMP-1/.
"
echo
echo "Copiando datos ..."
echo "rsync $OPTS $DATOS $RSERVER"
rsync $OPTS $DATOS $RSERVER
echo "OK"

echo
echo "Hora Fin: $(date)"
echo "=)"
The Rsyn is working OK. What i need is to change one of the lines of the /tmp/prueba.txt before sending it to the remote machine (obviously not changing the file in the local machine), i mean, send prueba.txt to the remote machine deleting one line and adding another one...how can i do this????

sed is a good choice, but no clue how to put all together in the same script...i would appreciate your help

BEST REGARDS!!!
 
Old 11-20-2010, 09:26 AM   #2
fcintron
Member
 
Registered: Oct 2010
Location: México
Distribution: Centos
Posts: 72

Rep: Reputation: 4
Quote:
Originally Posted by danndp View Post
Hello my friends,

I'm configuring an rsync between 2 machines, A_Server --> B_Server, using the following script:

Code:
#!/bin/bash
#
# Script de backup a través de Rsync desde RMP-1 hasta RMP-2.
#
# Si se produce algún error en cualquier momento abortar.
#set -e

DATOS="/tmp/prueba.txt"
EXCLUDES=
OPTS="-vv --relative --delete --force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES -a"
RSERVER="rsync://A_Server@192.168.1.4/A_Server/"
export RSYNC_PASSWORD=1234

#Este script sincroniza los datos de Asterisk de RMP-1 a RMP-2 a través 
#del servicio rsyncd. Los datos se guardan en RMP-2 en la carpeta 
#/home/RMP-1/.
"
echo
echo "Copiando datos ..."
echo "rsync $OPTS $DATOS $RSERVER"
rsync $OPTS $DATOS $RSERVER
echo "OK"

echo
echo "Hora Fin: $(date)"
echo "=)"
The Rsyn is working OK. What i need is to change one of the lines of the /tmp/prueba.txt before sending it to the remote machine (obviously not changing the file in the local machine), i mean, send prueba.txt to the remote machine deleting one line and adding another one...how can i do this????

sed is a good choice, but no clue how to put all together in the same script...i would appreciate your help

BEST REGARDS!!!

There are two utilities called diff and patch. With diff you can find the diferrences between two files. And patch is used to apply these differences.

There is and explanation in this link.

http://stephenjungels.com/jungels.ne...n-minutes.html


Regards

Last edited by fcintron; 11-20-2010 at 09:28 AM.
 
  


Reply



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
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 06:07 PM
[SOLVED] shell script to copy newly changed files with rsync genderbender Programming 15 04-22-2010 07:27 AM
why block number changed after change of file? bitzsk Linux - Kernel 2 06-05-2009 07:10 AM
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 01:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:14 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
Open Source Consulting | Domain Registration