10-20-2008
Script to move files based on Pattern don't work
Hi people,
i need you help on this if you can.
I have a script that does the move command when it searches for a that doesn't match the pattern. This Pattern is on a list.
When it run's and doesn´t found no files but it haves 2 more folders it moves the folders too.
Ex:
WORKDIR=R:/mdi_prod
SCRIPTS=R:/Deployment/MDI/PROD
LOGS=$SCRIPTS/LOGS
CONF=conf_file_FTP.conf
GETF=`cat $SCRIPTS/$CONF`
stamp=`/usr/bin/date +"%Y%m%d%H%M"`
####################################### **** FUNCOES ***
##################################################
cd $WORKDIR
for i in $GETF
do
teste1=`echo $i | awk -F ';' '{print $1}'`
echo $teste1 >> $LOGS/Check_files_1_$stamp.log
teste2=`echo $i | awk -F ';' '{print $2}'`
echo $teste2 >> $LOGS/Check_files_1_$stamp.log
teste3=`echo $i | awk -F ';' '{print $3}'`
echo $teste3 >> $LOGS/Check_files_1_$stamp.log
cd $WORKDIR/$teste2 >> $LOGS/Check_files_1_$stamp.log
basico=`ls -I "$teste3" | grep -v Historico`
echo $basico >> $LOGS/Check_files_1_$stamp.log
for j in `echo $basico`
do
cp $WORKDIR/$teste2/$j $WORKDIR/ERROR_FILES >> $LOGS/Check_files_1_$stamp.log
sleep 5
done
echo cd $WORKDIR >> $LOGS/Check_files_1_$stamp.log
done
exit
The list :
FRROGET;edpst/Forwards/Reuters/Reuters_Others;????????_Reuters_Forward_Others.xls
CURGET;edpst/Previsiones/CUR;CUR_????????_v*.xls
PMPTGET;edpst/Previsiones/MIBEL_PT;prev_portugal_????????.xls
POGET;edpst/Previsiones/OMIP;OMIPdaily_??-??-????.xls
NESPGET;NEO_ESPANHA;AS_????????.xls
NPCNGET;NEO_ESPANHA/PREV_COGEN_NEO;REMercado_*_????????.red
NEOFREDFGET;NEO_FRANCA/curvas_EDF;EDF_*.txt
NEOFRANCURVDGET;NEO_FRANCA;0000*.cdc
CONSANPREVGET;HC/CONSUMO_ANUAL_PREVISTO;CONSUMO_ANUAL_PREVISTO_*.csv
CPEENERGET;EOL_PORTUGAL/CargadorProdEEEnernova;PE_Enernova_??_a_????????.xls
CPEESPTGET;EOL_PORTUGAL/CargadorProdEESubestacionPT;PE_Agregados_SE_?????_???????.xls
For example, the folder NEO_ESPANHA all files that doesn't match the pattern " AS_????????.xls" but me moved to a folder of ERROR_FILES. What appens is it move the subfolders too when i do a ( ls -I "AS_????????.xls" ).
I'm doing this on the Cygwin tool.
Can someone help me ?
Regards
osramos
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, I'm trying to write a bash script to find some files. However it seems that the find command is not behaving the same way when the script is executed as it does when executed from the command line:
Script extract:
#!/bin/bash
...
NEW="/usr/bin/find current/applications/ -name '*jar'... (3 Replies)
Discussion started by: mattd
3 Replies
2. Shell Programming and Scripting
I am looking for advice on how to write a script that will rename and/or move files to a different directory based upon the results of a grep.
Let's say I have ten files in a directory. Some of them - not all - contain the text 'HELLO'. I would like to be able to grep the files for that text,... (3 Replies)
Discussion started by: rjhjr64
3 Replies
3. Solaris
Hi all.
The startup script in /usr/local/bin.
After user login the script run an application.
Iwould in the same way run the another application.
How to make It similar?
Where I must to look?
Regards. (3 Replies)
Discussion started by: wolfgang
3 Replies
4. Shell Programming and Scripting
Hi folks,
I'm new here and appreciate greatly any help.
I have a bunch of files that need be moved and renamed. Fortunately, they are all in sequence...
Present filename and path: /.catalog1/t76038_842-01
Move to: /.catalog1/76038-01
So, we need to drop the... (8 Replies)
Discussion started by: axslinger
8 Replies
5. UNIX for Dummies Questions & Answers
Hy again guys,
Last week i resolve a question here but now i need your help again :rolleyes:
I have about 3000 files that i need to choose based on the lowest value, so i make temp files like this:
The files can have lines from 1-10 but only 2 columns, the point is to grep the name os the... (2 Replies)
Discussion started by: MetaBolic0
2 Replies
6. UNIX for Dummies Questions & Answers
Hi ,
I need a script which moves files based on month. Example :
Apr 29 03:16 log4.txt
Apr 29 03:16 log5.txt
May 4 09:17 log1.txt
May 4 09:17 log2.txt
Move Apr files into Apr2015(Folder)
Move May files into May2015(Folder).
This is urgent requirement , if you can help me... (5 Replies)
Discussion started by: rockingvj
5 Replies
7. Shell Programming and Scripting
Dear All,
I would like move some directories in another location.
Basically, my ls -lis
drwxr-xr-x 3 XXXXXXXXXXXXXXXXXXXX 4096 Feb 24 02:18 data.N701_N502.ABCDE
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 185865797 Feb 23 11:27 data.N701_N502.ABCDE_file1
-rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies
8. Shell Programming and Scripting
Hi Guys,
I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies
9. Shell Programming and Scripting
Hello,
First time poster. I am looking for a way to script or program the process of moving files from one folder to another, automatically, based on the count of files in the destination folder.
I was thinking a shell script would work, but am open to the suggestions of the experts... (6 Replies)
Discussion started by: comtech
6 Replies
10. UNIX for Beginners Questions & Answers
Hi All-I am new to Unix , I need to write a script. Can someone help me with a requirement where I have list of files in a directory, I want to Merge the files if a pattern of string matches in filenames?
AAAL_555A_ORANGE1_F190404.TXT
AAAL_555A_ORANGE2_F190404.TXT
AAAL_555A_ORANGE3_F190404.TXT... (6 Replies)
Discussion started by: Shankar455
6 Replies
LEARN ABOUT MOJAVE
tcl_stringcasematch
Tcl_StringMatch(3) Tcl Library Procedures Tcl_StringMatch(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_StringMatch, Tcl_StringCaseMatch - test whether a string matches a pattern
SYNOPSIS
#include <tcl.h>
int
Tcl_StringMatch(str, pattern)
int
Tcl_StringCaseMatch(str, pattern, flags)
ARGUMENTS
const char *str (in) String to test.
const char *pattern (in) Pattern to match against string. May contain special characters from the set *?[].
int flags (in) OR-ed combination of match flags, currently only TCL_MATCH_NOCASE. 0 specifies a case-sensitive search.
_________________________________________________________________
DESCRIPTION
This utility procedure determines whether a string matches a given pattern. If it does, then Tcl_StringMatch returns 1. Otherwise
Tcl_StringMatch returns 0. The algorithm used for matching is the same algorithm used in the string match Tcl command and is similar to
the algorithm used by the C-shell for file name matching; see the Tcl manual entry for details.
In Tcl_StringCaseMatch, the algorithm is the same, but you have the option to make the matching case-insensitive. If you choose this (by
passing TCL_MATCH_NOCASE), then the string and pattern are essentially matched in the lower case.
KEYWORDS
match, pattern, string
Tcl 8.5 Tcl_StringMatch(3)