selecting files with text extension


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting selecting files with text extension
# 1  
Old 11-09-2011
selecting files with text extension

I have a script that read some values from the properties file and move files from source folder to destination folder based upon the modification time of the files created (N configurable days), rite now it pick up all types of files from source folder and put it into destination folder the script is working perfect......

below is the structure of properties file
********************************************

Code:
#This is the source directoy from where the files will be picked up
SrcDirectory=/home/p2000/sxs137/ODS_Project/temp


#This directory path should end with a slash(/)
DestDirectory=/home/p2000/sxs137/ODS_Project/test/


#Configurable N days value is assumed here of 3 days
Days=3

below is the code of the main script file
****************************************
Code:
#!/bin/sh 

. /home/p2000/sxs137/scripts/archievefilemovement.config

awk -F = '/Days=/{days=$2}/SrcDirectory=/{src=$2}/DestDirectory=/{dest=$2}END{print days, src, dest}' \
archievefilemovement.config |while read DAYS INDIR OUTDIR

do  

  find $INDIR -type f -mtime -$DAYS -exec mv {} $OUTDIR \;


Now I want to add extra functionality in the above properties file that it should pick the text files from the source folders as earlier it was picking up up all the files now it should pick up only the text files that is the main properties file would be now.....


Code:
#This is the source directoy from where the files will be picked up
  SrcDirectory=/home/p2000/sxs137/ODS_Project/temp
  
  
  #This directory path should end with a slash(/)
  DestDirectory=/home/p2000/sxs137/ODS_Project/test/
  
  
  #Configurable N days value is assumed here of 3 days
  Days=3

  #the pattern of the files
   SourcefilePattern=*.txt


Now there would be changes in the main script file also please guide how the main script file would be now ..!!Thanks in advance Smilie
# 2  
Old 11-09-2011
@nks342.. Please come up with what you have tried earlier because it would be more easier for us to help you..

Thanks for the co-operation .. Anyway below is your expected code.

Code:
#!/bin/sh 
. /home/p2000/sxs137/scripts/archievefilemovement.config
awk -F = '/Days=/{days=$2}/SrcDirectory=/{src=$2}/DestDirectory=/{dest=$2}/SourcefilePattern=/{pattern=$2}END{print days, src, dest, pattern}' \
archievefilemovement.config |while read DAYS INDIR OUTDIR PATTERN
do  
  find $INDIR -name "$PATTERN" -type f -mtime -$DAYS -exec mv {} $OUTDIR \;
done

# 3  
Old 11-09-2011
This is the same question of this thread which is closed by other mods.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Selecting text on multiple lines, then removing a beginning and end patterns

I have a file similar to the below. I am selecting only the paragraphs with @inlineifset. I am using the following command sed '/@inlineifset/,/^ *$/!d; s/@inlineifset{mrg, @btpar{@//' $flnm >> $ofln This produces @section Correlations between seismograms,,,,}} ... (5 Replies)
Discussion started by: Danette
5 Replies

2. Shell Programming and Scripting

Comparing two one-line files and selecting what does not match

I have two files. One is consisting of one line, with data separated by spaces and each number appearing only once. The other is consisting of one column and multiple lines which can have some numbers appearing more than once. It looks something like this: file 1: 20 700 15 30 file2: 10... (10 Replies)
Discussion started by: maya3
10 Replies

3. UNIX for Dummies Questions & Answers

Issue with selecting the text in gvim

Hi, I wanted to select the text in gvim using mouse for coping. some times it works fine and full text will be selected and copied to clipboard if it is like shown in first fig. Paste of the copied text can be done by clicking the middle mouse button. But some times the text will be selected as... (2 Replies)
Discussion started by: twistedpair
2 Replies

4. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

5. Shell Programming and Scripting

awk for selecting columns of different data files

Hello friends, How can I use awk commands to obtain selective blocks from different data files. For example file1 a b c d e f g h i file2 1 2 3 4 5 6 7 8 9 output a b 2 3 d e 5 6 g h 8 9 is it possible ? (2 Replies)
Discussion started by: rpf
2 Replies

6. Shell Programming and Scripting

selecting certain files

Hi, I have been working on a punch of codes and I got to a problem I hope to get help on. I have some files that I want to work with but the folder has other files in it. For example: The folder contains these files: path to files: /home/distribution/ ls: b.10; b.11; b.12; b.20; b.222;... (2 Replies)
Discussion started by: iconig
2 Replies

7. Programming

Selecting files in regular intervals from a folder

Hi, I need your expertise in selecting files from a folder. I have files named with convention: filename.i.j where j is an interger from 1 to 16, for each i which is an integer from 1 to 2000. I would like to select the files with i in regular interval of 50 like filename.1.j,... (2 Replies)
Discussion started by: rpd25
2 Replies

8. Shell Programming and Scripting

Add text before extension

Hi , I have a txt file , in which there are multiple lines, I want to add .1cdb before each .txt file. Source data DB_SOURCE=DWHCBU #Generate_file=/root/cbu/src/ET_CDR_SCAN.txt(# is a part of the data) TARGET=DWHEDW #Generate_TG_FILE=/root/cbu/src/ET_CDR_SCAN.txt DB_SOURCE=DWHCBU... (3 Replies)
Discussion started by: mora
3 Replies

9. Shell Programming and Scripting

Selecting a part of the text (regex pattern, awk, sed)

Hello, let's start by giving you guys a few examples of the text: "READ /TEXT123/ABC123" "READ /TEXT123/ABC123/" "READ TEXT123/ABC123" "READ TEXT123/ABC123/" "READ TEXT123/TEXT456/ABC123" "READ /TEXT123/TEXT456/ABC123" "READ /TEXT123/TEXT456/ABC123/" TEXT and ABC can be and I... (5 Replies)
Discussion started by: TehOne
5 Replies

10. Shell Programming and Scripting

Selecting Lines on text file

Hi All, I am creating a script that sends log data from text files to a Database and I will like to read sugestions, as I think that there might be better ways to achive this than with my shell script; maybe perl or I don't know, but I will like to read some sugestions. The log is from... (10 Replies)
Discussion started by: oconmx
10 Replies
Login or Register to Ask a Question