Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. stdout = 1
  2. stderr = 2
  3.  
  4. ทีนี้ ลอง demo สร้าง file ขึ้นมาก่อน
  5. `touch file_{01..99}`
  6. จากนั้น ลองเปลี่ยน permission
  7. `chmod 000 *1*`
  8. แล้วลอง copy ไปไว้ที่ folder อื่นๆ
  9. `cp -v file_* folder/ 1>success.log 2>fail.log`
  10.  
  11. ```log
  12. cat fail.log
  13. cp: file_01: Permission denied
  14. cp: file_10: Permission denied
  15. cp: file_11: Permission denied
  16. cp: file_12: Permission denied
  17. cp: file_13: Permission denied
  18. cp: file_14: Permission denied
  19. ```
  20.  
  21. error จะไปโผล่ใน fail.log ขณะที่ success.log จะมีแค่ file ที่ copy สำเร็จ .
  22. ถ้าจะ redirect output&error ไปที่เดียวกันก็ ใช้ & แทนทั้งคู่ได้ .
  23. `cp -v file_* folder/ &> output.log` .
  24.  
  25. หรือส่งมันไปที่หลุมดำ .
  26. `ls -l &> /dev/null`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement