Sponsored Content
Top Forums Shell Programming and Scripting Shell scripting-I need a script which should watch a directory for a file with specific directory Post 302912958 by akashdeepak on Wednesday 13th of August 2014 02:31:06 AM
Old 08-13-2014
This is what I had been trying to get it done.
But problem comes when I use cut command to get the key. It cuts all the fields at once because of which I am not able to use it in if command.

Code:
# Function for file watching
  function mailMsg
{

    if [ $# -ne 3 ]
    then
        echo "ERROR: Usage is $0 MAIL_SUBJECT MAIL_RECIPIENT MAIL_MESSAGE"
        return 1
    fi
    mail -s "$1" $2 <<ENDMAIL
    $3
 
ENDMAIL
}


nDEF_EDI_ADMIN_EMAIL=adeepak@visteon.com,cgd@qad.com
DEF_EDI_LOG=/ediec/log/"${CURR_PRG_NAME}".log
DEF_EDI_TEMP_DIR=/ediec/3271010/in/tempin
DEF_EDI_IN_DIR=/ediec/3271010/in/
echo `pwd`
cd /ediec/3271010/in/tempin 
echo `pwd`
CSG2="CSG2"
ARD1="ARD1"
Dockcodes="Dockcodes.txt"
#while true
#do
    file_list=$( ls GEFCO_INVRPTB9PDB* 2>/dev/null )
    if [ -n "{$file_list}" ];  
    then
       #echo "inside in"
	for file_name in ${file_list};
	 do
	  echo "file_name" $file_name
	   tt=`grep -i CSG2 ${file_name}` >> Dockcodes.txt
	   aa=`grep -i ARD1 ${file_name}` >> Dockcodes.txt

	   #echo "dock" $dock "part" $part
	  # while read aline
	#	  do
			# echo "ttemp2.txt"
			#cat temp2.txt
			key=`cut -c1-4 Dockcodes.txt`
			echo "key" $key
			if [ $key = 'CSG2' ]
			then
				dock=`cut -c5-20 Dockcodes.txt`
				echo $dock
                        fi
			if [ $key = 'ARD1' ]
			then
				part=`cut -c5-40 Dockcodes.txt` 
				qty=`cut -c93-107 Dockcodes.txt`
			fi
                     echo "dock" $dock "part" $part "qty" $qty 
         #        done < Dockcodes.txt
           #echo "Dockcodes.txt"
	   #cat Dockcodes.txt
	   #rm Dockcodes.txt

  	   #echo "inside for ${file_name}"
	   #cat $file_name >> temp.txt
          # mailMsg "${file_name} has been moved to ${DEF_EDI_IN_DIR} directory" "${DEF_EDI_ADMIN_EMAIL}" ""
          # mv ${file_name} ${DEF_EDI_IN_DIR}
	  #echo "before done"
	 done 
    fi


Last edited by rbatte1; 08-14-2014 at 06:12 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

script to watch changes on a directory

Hi, everybody I want to know hot to watch changes on a dir, for example if someone changes a file inside it, with an script. I've tried using md5sum and then diff, sadly with no success. I use md5sum for single files, but doesn't work for directories. The idea is take a snapshot with md5sum,... (4 Replies)
Discussion started by: piltrafa
4 Replies

2. Shell Programming and Scripting

shell scripting with directory

I have a directory /ndata/nmk I want to have 4 copies of my daily database backups like /ndata/nmk/copy1 /ndata/nmk/copy2 till copy4 . where copy1-copy4 are directories having my db backups . Once my db backups reach 4 directories like copy4 i want to again write from copy1 to copy4 . ... (3 Replies)
Discussion started by: suku123
3 Replies

3. UNIX for Advanced & Expert Users

Watch directory and move specific file extensions

Hi all, This is actually more for my lazyness then anything else, but I think others might find it useful to use as well. Basically this is what I am trying to achieve... In my ubuntu home dir under Downloads is where firefox saves everything by default, now I know that you can manually... (3 Replies)
Discussion started by: STOIE
3 Replies

4. Web Development

Directory index forbidden by Options directive error on specific directory with indexing disabled

I am seeing the following error appear numerous times in my Apache error log: I have my Apache config configured as below, so I would expect indexing not to occur on this directory as it falls under the parent /web directory. Strangely all the IP address, including this example, all... (5 Replies)
Discussion started by: crmpicco
5 Replies

5. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

6. Shell Programming and Scripting

Moving Files one directory to another directory shell script

Hi, Could you please assist how to move the gz files which are older than the 90 days from one folder to another folder ,before that it need to check the file system named "nfs" if size is less than 90 or not. If size is above 90 then it shouldn't perform file move and exit the script throwing... (4 Replies)
Discussion started by: venkat918
4 Replies

7. UNIX for Beginners Questions & Answers

How to zip csv files having specific pattern in a directory using UNIX shell script?

I have files in a Linux directory . Some of the file is listed below -rw-rw-r--. 1 roots roots 0 Dec 23 02:17 zzz_123_00000_A_1.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_121_00000_A_2.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_124_00000_A_3.csv drwxrwxr-x. 2 roots roots 6 Dec 23... (4 Replies)
Discussion started by: Balraj
4 Replies

8. Shell Programming and Scripting

Script to Tar file in a specific Directory

I'm trying to write a Unix script that will go to a specific directory (/tmp/Sanbox/logs) and tar.gz all the log files in that directory and delete the original files that are older than 2 days. So far I have this but it doesn't work. Any help would be appreciated. #!/bin/bash ... (7 Replies)
Discussion started by: Loc
7 Replies

9. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

10. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies
bup-margin(1)						      General Commands Manual						     bup-margin(1)

NAME
bup-margin - figure out your deduplication safety margin SYNOPSIS
bup margin [options...] DESCRIPTION
bup margin iterates through all objects in your bup repository, calculating the largest number of prefix bits shared between any two entries. This number, n, identifies the longest subset of SHA-1 you could use and still encounter a collision between your object ids. For example, one system that was tested had a collection of 11 million objects (70 GB), and bup margin returned 45. That means a 46-bit hash would be sufficient to avoid all collisions among that set of objects; each object in that repository could be uniquely identified by its first 46 bits. The number of bits needed seems to increase by about 1 or 2 for every doubling of the number of objects. Since SHA-1 hashes have 160 bits, that leaves 115 bits of margin. Of course, because SHA-1 hashes are essentially random, it's theoretically possible to use many more bits with far fewer objects. If you're paranoid about the possibility of SHA-1 collisions, you can monitor your repository by running bup margin occasionally to see if you're getting dangerously close to 160 bits. OPTIONS
--predict Guess the offset into each index file where a particular object will appear, and report the maximum deviation of the correct answer from the guess. This is potentially useful for tuning an interpolation search algorithm. --ignore-midx don't use .midx files, use only .idx files. This is only really useful when used with --predict. EXAMPLE
$ bup margin Reading indexes: 100.00% (1612581/1612581), done. 40 40 matching prefix bits 1.94 bits per doubling 120 bits (61.86 doublings) remaining 4.19338e+18 times larger is possible Everyone on earth could have 625878182 data sets like yours, all in one repository, and we would expect 1 object collision. $ bup margin --predict PackIdxList: using 1 index. Reading indexes: 100.00% (1612581/1612581), done. 915 of 1612581 (0.057%) SEE ALSO
bup-midx(1), bup-save(1) BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <apenwarr@gmail.com>. Bup unknown- bup-margin(1)
All times are GMT -4. The time now is 01:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy