Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Mv command in for loop - not working Post 303004850 by SIMMS7400 on Tuesday 10th of October 2017 07:28:10 AM
Old 10-10-2017
Wow Scott - thank you.

Yes, that was exactly it. The directory is massive and I didn't realize there were other similarly named files out there. What I have done is create an archive process to be executed once the processing is complete.

Then when the ftp process lands the new files, there wont be any conflicts.

My code is as follows:

Code:
Archive() {

cd /hypbin/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1/app/dailyinv/dailyinv

_ARCHIVEPATH=Archives/AWI_GSC_Archives/${CR_YR}_${ydate}/
mkdir -p "${_ARCHIVEPATH}"

for A in GSCXMITINV AWIXMITINV
do
    if ls ${A}* 1> /dev/null 2>&1
    then
        echo "$A is available for processing"
        mv ${A}* "${_ARCHIVEPATH}"
    else
        echo "$A does not exist - file will not be archived"
    fi  
done

cd /hypbin/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1/app/item/itmsales

_ARCHIVEPATH=Archives/AWI_GSC_Archives/${CR_YR}_${ydate}/
mkdir -p "${_ARCHIVEPATH}"

for A in AWID601 GSCD601
do
    if ls ${A}* 1> /dev/null 2>&1
    then
        echo "$A is available for processing"
        mv ${A}* "${_ARCHIVEPATH}"
    else
        echo "$A does not exist - file will not be archived"
    fi  
done

}

cd /hypbin/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1/app/dailyinv/dailyinv

for A in GSCXMITINV AWIXMITINV
do
    if ls ${A}${CR_YR}* 1> /dev/null 2>&1
    then
        echo "$A is available for processing"
        mv ${A}${CR_YR}*.TXT ${A}${ydate}.TXT
    else
        echo "$A does not exist - data import process aborted"
        exit 1
    fi  
done

cd /hypbin/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1/app/item/itmsales

for A in AWID601 GSCD601
do
    if ls ${A}${CR_YR}* 1> /dev/null 2>&1
    then
        echo "$A is available for processing"
        mv ${A}${CR_YR}*.TXT ${A}${ydate}.TXT
    else
        echo "$A does not exist - data import process aborted"
        exit 1
    fi  
done

cd /hypbin/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1/scripts/tivoli/dailysales

perl 2passdatechange.pl
sleep 60
startMaxl.sh oraclez.mxl ${CR_YR}

#::-- Archive data files after execution --::#
Archive

Thank you all for your help!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop not working

Apologize if this is doesn't come under this group. I have a small script to find out users who last logged in to check there mail. (Tru 64 4.0, Netscape mail 3.6) -----> cat $1|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/ {s=$5;u++;las=substr($1)} END {for (i in u) {print... (2 Replies)
Discussion started by: nitin
2 Replies

2. Shell Programming and Scripting

if loop is not working

Hello i am trying to remove a line using an input file , but this depends upon user interaction here is the sample #!/bin/sh echo "Please enter whether you want to remove Profile" read value1 if ;then sed /movie/d temp.txt> temp3.txt else echo "Script didnot remove profile" fi ... (3 Replies)
Discussion started by: ranga27
3 Replies

3. Shell Programming and Scripting

For loop not working...! :(

Could some one help me on this... For loop is working...! for x in $i do for y in $j do z=`echo $y | awk '{print $2}'` if then FS=`/usr/bin/echo $y` echo $FS >>$Basic_location/out.csv fi done CPRT="Cpoyright @ BTOIDCIM" done (3 Replies)
Discussion started by: bullz26
3 Replies

4. UNIX for Dummies Questions & Answers

If then else loop not working

If then else segment of below code is not working. For each filename code is displaying output for if part as well as else part. Please help its urgent. for usercusttop in `echo ${filename}|sort|uniq|cut -c 1-${actualwordcount}` do ... (2 Replies)
Discussion started by: findprakash
2 Replies

5. UNIX for Advanced & Expert Users

If loop is not working

The following piece of code is not running because it is fails to go inside the if condition. i want to create a directory if there is no directory in the input path. i am using Linux, by CENT. Please help. echo " Enter the path where you u want to extract the tar" read EXTRACT_PATH ls -ld... (12 Replies)
Discussion started by: toanilsharma1
12 Replies

6. Shell Programming and Scripting

While loop not working

here we go.. While loop is not working file.. It also invokes one more shell scripts for which parameters need to passed on. while read line do #### #### We want to have a logfile for each load #### PLog="${LogDir}/${Script}.log"; #### ... (5 Replies)
Discussion started by: premkumardr
5 Replies

7. Shell Programming and Scripting

For loop not working

Hi All, For loop in ksh not working if it was given in the following method. simple script: for i in {1..4} do echo $i done Output: {1..4} Even below also not working :( Script: for (( c=1; c<=5; c++ )) do echo "Welcome $c times..." done Output: ./x.sh: 0403-057 Syntax error... (13 Replies)
Discussion started by: girish_satyam
13 Replies

8. Programming

C While Loop not working like C++

Hi new to C give me a hand thank. do { bzero(input,256); printf("Please enter the country name!"); scanf("%s",input); //& character is essential for scanf(), %f = float, %399s as the last character to be the null character ('\0'). } while... (5 Replies)
Discussion started by: GQiang
5 Replies

9. Shell Programming and Scripting

Cut command not working in for loop

grep -Fxvf testdata.xls file_GTDA1.xls >file_GTDA.xls SLS_COUNT=`grep 'GTDA_Dly_Sls' file_GTDA.xls |wc -l` PMIX_COUNT=`grep 'GTDA_Dly_Pmix' file_GTDA.xls |wc -l` if ; then var1=`cat file_GTDA.xls|grep 'GTDA_Dly_Sls_'` var4="|" for i in $var1... (7 Replies)
Discussion started by: renuk
7 Replies

10. Shell Programming and Scripting

For-loop not working

Hello all, I would like to unzip some files with a for-loop. Is there anyone who could tell me how I should do this - in a correct way? for file in $(ls); do echo gzip -d < $file | tar xf -; done The problem is the pipe - I believe. But how could I do it? I need it for the command... (4 Replies)
Discussion started by: API
4 Replies
foreach(1T)						       Tcl Built-In Commands						       foreach(1T)

__________________________________________________________________________________________________________________________________________________

NAME
foreach - Iterate over all elements in one or more lists SYNOPSIS
foreach varname list body foreach varlist1 list1 ?varlist2 list2 ...? body _________________________________________________________________ DESCRIPTION
The foreach command implements a loop where the loop variable(s) take on values from one or more lists. In the simplest case there is one loop variable, varname, and one list, list, that is a list of values to assign to varname. The body argument is a Tcl script. For each element of list (in order from first to last), foreach assigns the contents of the element to varname as if the lindex command had been used to extract the element, then calls the Tcl interpreter to execute body. In the general case there can be more than one value list (e.g., list1 and list2), and each value list can be associated with a list of loop variables (e.g., varlist1 and varlist2). During each iteration of the loop the variables of each varlist are assigned consecutive values from the corresponding list. Values in each list are used in order from first to last, and each value is used exactly once. The total number of loop iterations is large enough to use up all the values from all the value lists. If a value list does not contain enough elements for each of its loop variables in each iteration, empty values are used for the missing elements. The break and continue statements may be invoked inside body, with the same effect as in the for command. Foreach returns an empty string. EXAMPLES
The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. set x {} foreach {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop. The next loop uses i and j to iterate over two lists in parallel. set x {} foreach i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop. The two forms are combined in the following example. set x {} foreach i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop. SEE ALSO
for(1T), while(1T), break(1T), continue(1T) KEYWORDS
foreach, iteration, list, looping ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl foreach(1T)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy