Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stdout = 1
- stderr = 2
- ทีนี้ ลอง demo สร้าง file ขึ้นมาก่อน
- `touch file_{01..99}`
- จากนั้น ลองเปลี่ยน permission
- `chmod 000 *1*`
- แล้วลอง copy ไปไว้ที่ folder อื่นๆ
- `cp -v file_* folder/ 1>success.log 2>fail.log`
- ```log
- cat fail.log
- cp: file_01: Permission denied
- cp: file_10: Permission denied
- cp: file_11: Permission denied
- cp: file_12: Permission denied
- cp: file_13: Permission denied
- cp: file_14: Permission denied
- ```
- error จะไปโผล่ใน fail.log ขณะที่ success.log จะมีแค่ file ที่ copy สำเร็จ .
- ถ้าจะ redirect output&error ไปที่เดียวกันก็ ใช้ & แทนทั้งคู่ได้ .
- `cp -v file_* folder/ &> output.log` .
- หรือส่งมันไปที่หลุมดำ .
- `ls -l &> /dev/null`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement