Sorting and columns · الفرز والأعمدة
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · تحتاج هذه الصفحة إلى متصفح حديث (يدعم SharedArrayBuffer). يرجى تحديث Chrome أو Edge أو Firefox أو Safari إلى أحدث إصدار.
English
Putting lines in order
sortarranges lines alphabetically (or, with-n, as numbers):
sort -rreverses the order;sort -nis for lists of numbers.
العربية
ترتيب الأسطر
sortيرتب الأسطر أبجدياً (أو، مع-n، كأرقام):
sort names.txt
sort -rيعكس الترتيب؛sort -nمخصص لقوائم الأرقام.
English
Removing duplicates
uniqremoves neighbouring repeated lines. Because it only looks at neighbours, you usuallysortfirst:
- Add
uniq -cto also count how many times each line appeared.
العربية
إزالة التكرارات
uniqيزيل الأسطر المكررة المتجاورة فقط. لأنه يفحص المجاورين فقط، فعادةً ما تحتاج إلىsortأولاً:
sort names.txt | uniq
- أضف
uniq -cلـعدّ كم مرة ظهر كل سطر.
Explore · استكشف
sort, then uniq · sort، ثم uniq
uniq only sees neighbours — sort first, so the duplicates sit together. · uniq يرى الجيران فقط — sort أولاً، لذا تجلس المكررات معاً.
English
Picking out columns
- Many files have columns separated by a character — a comma, a colon, a tab.
cutpulls out the columns you want.-dsets the delimiter,-fthe field:
- That takes the first field of each
name:ageline — the names.
العربية
استخراج الأعمدة
- العديد من الملفات تحتوي على أعمدة مفصولة بـحرف — فاصلة، نقطتين رأسيتين، أو زر تبويب.
cutيستخرج الأعمدة التي تريدها.-dيحدد الـfاصل،-fالـfيلد:
cut -d : -f 1 people.txt
- هذا يأخذ الحقل الـأول من كل سطر
name:age— وهي الأسماء.
English
Common mistakes
sortis alphabetical;sort -nsorts numbers correctly.cutneeds the right delimiter with-d.
العربية
أخطاء شائعة
sortأبجدي؛sort -nيرتب الأرقام بشكل صحيح.cutيحتاج الفاصل المناسب مع-d.
Get a tidy, de-duplicated list of names. Pipe sort into uniq: sort names.txt | uniq. · احصل على قائمة نظيفة خالية من المكررات للأسماء. أنبوب sort إلى uniq: sort names.txt | uniq.
people.txt has name:age on each line. Pull out just the names with cut -d : -f 1 people.txt. · people.txt يحتوي name:age في كل سطر. اسحب الأسماء فقط باستخدام cut -d : -f 1 people.txt.