Showing posts with label find. Show all posts
Showing posts with label find. Show all posts

Tuesday, October 25, 2011

how to move multiple file with CLI

การย้ายไฟล์จากที่หนึ่งไปยังอีกที่หนึ่ง ปกติแล้วถ้าหากใช้ Windows ก็จะเลือกไฟล์หลาย ๆ ไฟล์จากนั้นก็ Drag & Drop file ไปไว้อีกทีนึงได้เลย แต่ถ้าเป็น CLI (Command Line Interface) ละจะทำอย่างไร?
หากต้องการ move file ทั้ง directory '/home/user/a' and rename directory to directory '/home/user/b' เลยอาจใช้คำสั่งนี้
mv /home/user/a /home/user/b
หาก /home/user/b exist can use this command
mv /home/user/a/* /home/user/b
ในขณะที่ file ที่ต้องการจะ move มีบางไฟล์จาก /home/user/a โดยที่ต้องการ move file ที่ไม่ได้ถูกเปลี่ยนแปลงมาแล้วเกินกว่า 30 วัน
find /home/user/a -type f -mtime +30 -exec mv '{}' /home/user/b \;

Read More