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מגדיר את delimiter, ו--fאת ה-field:
cut -d : -f 1 people.txt
- פקודה זו לוקחת את ה-first field של כל שורת
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.