Sponsored Content
Top Forums Shell Programming and Scripting Korn shell script to sync/move files that are not in use Post 302563470 by linuxn00b on Tuesday 11th of October 2011 10:06:18 AM
Old 10-11-2011
still having problems

so I have a few ideas in place here from some stuff I have came across on this forum and online. But I am missing something in each of these scripts. Ideas welcome please. What am I missing here??? Smilie

Code:
#!/usr/bin/ksh

FILE_NAME=$i
FILE_OPEN=`lsof | grep $FILE_NAME`
ls -l /usr/local/bin/test | while read a b c d e f g h i; do
	if [ -z $FILE_OPEN ] ;then
		echo "File NOT open"
	else
		echo "File Open"
	fi
done

Code:
#!/usr/bin/ksh

file1=`cksum $i | awk '{print $1}'`
sleep 10
file2=`cksum $i | awk '{print $1}'`

ls -l /usr/local/bin/test | while read a b c d e f g h i ; do
	if [  $file1 = $file2 ] ; then
		echo "Both are same" $file1 $file2
	else
		echo "Both are different" $file1 $file2
	fi
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Lookup between 2 files ( korn shell )

Hi All., i have a problem. I hope i can get some help on this issue here; i have 2 txt files say file1 and file 2 file1 has; WLMT:XXXXXXXX:cp DOLR:YYYYYYY:ascii,unblock WLG:TTTTTTT:dd:73:ascii,unblock MAR:SSSSSS:dd:152:ascii,unblock GGG:QQQQQQQQQQ:112:ascii,unblock EIE:CCCCCCCC:cp... (17 Replies)
Discussion started by: pavan_test
17 Replies

2. UNIX for Dummies Questions & Answers

Korn shell awk use for updating two files

Hi, I have two text files containing records in following format: file1 format is: name1 age1 nickname1 path1 name2 age2 nickname2 path2 file 1 example is: abcd 13 abcd.13 /home/temp/abcd.13 efgh 15 efgh.15 /home/temp/new/efgh.15 (4 Replies)
Discussion started by: alrinno
4 Replies

3. UNIX for Dummies Questions & Answers

Initializing files to empty in korn shell

hello, i want to know how to initialize a file to an empty one in korn shell scripting? i'm using a file name and building it during a while loop using >>. The problem occurs when the file is not empty before reaching the while loop. therefore, i want to initialize it before the loop to get... (6 Replies)
Discussion started by: alrinno
6 Replies

4. Shell Programming and Scripting

Shell script to move certain files on scheduled time

Hi Friends, I want a shell script which will move certain .jar files from a specified location (say /publish/content) to (/publish/archive) on every saturday morning 6 am. One more thing to add is that before moving files it must check free space at (/publish/archive), if it is more than 60 %... (7 Replies)
Discussion started by: abhishek27
7 Replies

5. Shell Programming and Scripting

Shell script to move files to 3 different folders

Hi guys: I've got this problem, I want to move a bunch of files to 3 different folders, without any specific order, and I'm trying to automatize it with a shell script. I'm a newbie at shell scripting so this is my first try: #!/bin/bash COUNTER=`ls -1 | wc -l` while do ARRAY=(... (11 Replies)
Discussion started by: wretchedmike
11 Replies

6. Shell Programming and Scripting

korn shell remove files question

how do you show each filename in a giving directory and delete the specific file in korn script i was thinking using ls rm ? but i cant make it work (0 Replies)
Discussion started by: babuda0059
0 Replies

7. Shell Programming and Scripting

Need shell script to move files

Hi , I need a simple shell script to move the files from one directory to another directory after every 1 hour..!!! ?? (1 Reply)
Discussion started by: SARAL SAXENA
1 Replies

8. Shell Programming and Scripting

crontab using shell script to sync files.

Hi, I developed one shell script where it will sync the files using perforce, #!/bin/bash TERM=linux export TERM clear echo "" $PATH echo "" cd /u/userk/p4/p4_client/TES_DATE echo "" echo "Sync p4 " p4 sync echo "Executing for second time " p4 -u userk -p p4net:161 -c... (8 Replies)
Discussion started by: asak
8 Replies

9. Shell Programming and Scripting

Korn shell Script to combine Two files in one

Hello All , I am new to this Forum, I am trying to write a script to combine two data files with 1 column in common and others columns are different . File1 Apple 29 tomatao 4 grapes 25 File2 Apple fruit tomatao veg grapes fruit other (3 Replies)
Discussion started by: gagan0119
3 Replies

10. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies
MRB(8)							      System Manager's Manual							    MRB(8)

NAME
mrb - manage incremental snapshots with rsync/make. SYNOPSIS
mrb command DESCRIPTION
mrb is a simple aid to creating efficient incremental snapshots of a set, or sets, of directories whenever that may be required. It may be used as part of a regular automated backup regime, or for manually checkpointing changes at convenient points in time. COMMANDS
The following commands are recognised (where 'MODULE' is the name of one of your snapshot definitions): new-MODULE Create a skeleton definition for a new snapshot 'MODULE'. dest-MODULE Create the destination dir for 'MODULE'. This directory must exist to create a snapshot. snap-MODULE Create a snapshot of 'MODULE'. sync Create snapshots of all defined modules. If run as root this may be configured to include the modules of other users too (see MRB_SYNC_USERS in ~/.mrb/defaults). help Show mrb's own help text. CONFIGURATION FILES
Per-user configuration The following files may be used to specify global and local configuration options. /etc/default/mrb system default configuration. ~/.mrb/defaults per-user configuration. Per-user options The following options control behaviour for all of a user's modules. MRB_SNAPSHOT_LOG An optional file path where transfer details will be recorded. If unset these details will not be logged. MRB_SYNC_USERS A space separated list of users whose modules should be included in a sync. This is mostly only useful for root, as mrb will assume the identity of each user before creating snapshots of their modules. If unset, only the invoking user's modules will be sync'ed. MRB_CONFDIR An space separated list of the directories to search for module definition (*.mrc) files. They will be searched in the order given, with new modules added by default to the last one listed. There should be few reasons to change the default value. Per-module configuration The default MRB_CONFDIR value will search for module definitions in: /etc/mrb/*.mrc ~/.mrb/*.mrc Those created by new-MODULE will be placed in this latter location by default. Per-module options In each case module below is the name of the particular module that the value set should apply to. These options should be defined in a file named module.mrc. module_SRC A space separated list of the files and (top level) directories to include in the snapshots for this module. module_DEST The directory root where snapshots of module should be stored. module_INCLUDE An optional list of rsync(1) include patterns. module_EXCLUDE An optional list of rsync(1) exclude patterns. module_FILTER An optional list of rsync(1) filter patterns. module_FILTER_FILE An optional filename for rsync(1) dir-merge filtering support. module_RSYNC_OPTIONS Optional additional rsync(1) options to pass verbatim when it is invoked. module_PRECOMMAND An optional shell command to invoke just prior to creating a new snapshot. If the command does not return a successful exit status, then the snapshot creation will be aborted before it begins. It may be used to mount removable media or similar. module_POSTCOMMAND An optional shell command to execute after making the snapshot. It will not be called if the snaphot creation failed at an earlier stage, and its return status may halt a sync operation if it fails with more modules still to process. It may be used, for example, to unmount removable media again. module_USER An optional user name to check that mrb is running as before performing a snapshot. This can be used to ensure you have the correct permisson to access the files being mirrored before you get too far. SEE ALSO
rsync(1), make(1). AUTHOR
mrb was written by Ron <ron@debian.org>. May 9, 2006 MRB(8)
All times are GMT -4. The time now is 01:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy