Uniq (Unix)
uniq là một tiện ích Unix, có chức năng gỡ bỏ các dòng trống và kề nhau trong văn bản. Nó là một loại chương trình lọc. Thôn…
Bài viết này cần thêm chú thích nguồn gốc để kiểm chứng thông tin. |
uniq là một tiện ích Unix, có chức năng gỡ bỏ các dòng trống và kề nhau trong văn bản. Nó là một loại chương trình lọc. Thông thường uniq được sử dụng kề sau lệnh sort. Nếu có tùy chọn -d, lệnh chỉ xuất ra các dòng có trùng, tùy chọn -c hiện ra số lần lặp của dòng.
Ví dụ: Để xem danh sách các dòng trong một tập tin, sắp xếp bởi số lần xuất hiện của dòng:
- sort file | uniq -c | sort -n
Các tùy chọn
- -u Chỉ hiển thị các dòng không lặp lại
- -d Không hiển thị các dòng không lặp lại
- -c Hiển thị một báo cáo gồm dòng và số lần xuất hiện trong văn bản, khi tùy chọn này được sử dụng, hai tùy chọn -u và -d bị bỏ qua dù có được đưa vào lệnh hay không.
- -i Bỏ qua hoa - thường khi so sánh các dòng
- -f Bỏ qua một số trường trong mỗi dòng
- -s Bỏ qua một số ký tự trong mỗi dòng
- -w Chỉ định số ký tự cần so sánh khi so sánh dòng, các ký tự sau đó được bỏ qua
- --help Hiển thị thông báo trợ giúp
- --version Hiển thị thông tin phiên bản
Xem thêm
Tham khảo
Liên kết ngoài
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.