ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Copy latest file to new directory in QSH

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy latest file to new directory in QSH

    Hi

    I can find latest file from below command
    Code:
    ls -rt ZFIDOCD_* | tail -1
    I need to rename it and copy it to new directory
    What I did was
    Code:
    cp 'ls -rt ZFIDOCD_* | tail -1' /d800/prd/ZTEST.CSV
    Below is the error
    Code:
    cp: 001-2113 Error found getting information for object ls -rt ZFIDOCD_* | ta
    il -1. No such path or directory.
    Is this possible in QSH ?

    Thanks


  • #2
    You're close. You need to use command substitution. Surround the command with $( and ). (There's another syntax, where you use backquotes, but I prefer this syntax.)



    cp $(ls -rt ZFIDOCD_* | tail -1) /d800/prd/ZTEST.CSV

    Comment


    • #3
      That is It!!
      Thanks Ted.

      Comment

      Working...
      X