How do I move the oldest or newest file in a directory to another with Mac OS X Terminal

后端 未结 4 579
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 06:19

I\'m trying to us the following command on Mac OSX 10.6 Terminal but it does not work..Any idea what I may be doing wrong?

These work...

List most recent

4条回答
  •  旧巷少年郎
    2021-01-25 07:06

    You're moving the newest file. Try

    mv `ls -t |tail -1` newdirname
    

    or

    mv `ls -tr |head -1` newdirname
    

    Working on my Ubuntu's bash.

提交回复
热议问题