This discussion is archived
1 2 Previous Next 20 Replies Latest reply: Jan 18, 2013 4:28 AM by Dude! Go to original post RSS
  • 15. Re: Issue in Unix Shell script
    Bopty Newbie
    Currently Being Moderated
    ls -lrt /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat
    -rw-r--r-- 1 orarms dba 0 Jan 2 05:31 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_020113053132.dat
    -rw-r--r-- 1 orarms dba 0 Jan 2 05:33 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_020113053348.dat
    -rw-r--r-- 1 orarms dba 0 Jan 2 05:36 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_020113053600.dat
    -rw-r--r-- 1 orarms dba 265 Jan 2 05:36 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_020113053657.dat
    -rw-r--r-- 1 orarms dba 265 Jan 2 23:20 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_020113232025.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 00:34 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113003414.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 00:35 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113003542.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 00:40 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113004009.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 00:42 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113004220.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 00:44 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113004440.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 00:46 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113004616.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 01:57 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113015736.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 01:59 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113015948.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:06 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113020645.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:08 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113020849.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:11 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113021133.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:12 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113021238.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:52 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113025234.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:56 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113025633.dat
    -rw-r--r-- 1 orarms dba 265 Jan 3 02:57 /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_030113025709.dat
  • 16. Re: Issue in Unix Shell script
    Jan-Marten Spit Explorer
    Currently Being Moderated
    man mv

    DESCRIPTION
    Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

    it does not say directories.

    suppose you have this tree

    directory ./arch1
    directory ./arch2
    file ./ff

    the command

    mv ff arch*

    will be expanded by shell to the command (so -before- the command is executed)

    mv ff arch1 arch2

    which means 'move ff and arch1 to arch2', as stated in the man of mv. that is clearly not what you intend to do..

    i am not sure why mv is complaining about PATH, but it would appear that the mv command is given paths that cease to exist during it's execution.

    a strace -e stat -f (assuming linux) on your move command would show you in detail what is going on.
  • 17. Re: Issue in Unix Shell script
    user12159859 Newbie
    Currently Being Moderated
    Hi Bobty,

    Please post how you are setting the ${DATA_DIR} and ${ARCHIVE}
    Let me see the exact commands.
    I assume this is using ksh, or sh, correct?


    Just for the heck of it, can you try these three statements and tell me the results:
    mv  ${DATA_DIR}/ABC*.dat  ${ARCHIVE}/
    mv  ${DATA_DIR}/ABC*.dat  ${ARCHIVE}   <==  this one without trailing slash
    
    mv   ${DATA_DIR}/ABC*  ${ARCHIVE}/
    mv   ${DATA_DIR}/ABC*  ${ARCHIVE}   <== this one without trailing slash
    
    mv   ${DATA_DIR}/*.dat  ${ARCHIVE}/
    mv   ${DATA_DIR}/*.dat  ${ARCHIVE}   <== this one without trailing slash
    Also, please post the full version of your operating system (and what flavor it is).
  • 18. Re: Issue in Unix Shell script
    moreajays Pro
    Currently Being Moderated
    Hi ,

    Better use this

    for i in 'find /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ | grep -i dat' 
    do
    mv $i $ARCHIVE;
    done
    or

    for i in 'ls -lrt  /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ | grep -i dat | awk '{ print $8}'' 
    do
    mv $i $ARCHIVE;
    done
    Thanks,
    Ajay More
  • 19. Re: Issue in Unix Shell script
    Bopty Newbie
    Currently Being Moderated
    Hi All,

    Thanks for you help. PFB the solution for the issue,

    ls ${DATA_DIR} | grep "ABC" | while read x; do echo $x; mv ${DATA_DIR}/$x ${ARCHIVE}; done



    Thanks,
    Bopty
  • 20. Re: Issue in Unix Shell script
    Dude! Guru
    Currently Being Moderated
    Why so complicated and not simply using the versatile find command? For instance:
    find $DATA_DIR -type f -iname "*abc*" -exec mv -f {} $ARCHIVE \; 
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points