Reading files · قراءة الملفات
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
Reading a file
catprints a file's contents straight to the screen:
- It is named after "concatenate" — it can also join several files together.
العربية
قراءة ملف
- أمر
catيطبع محتويات ملف مباشرة على الشاشة:
cat poem.txt
- سُمّي بناءً على كلمة "concatenate" — يمكنه أيضاً دمج عدة ملفات معاً.
English
Just the start or end
- For a long file you often want only a peek:
headshows the first lines,tailshows the last lines.
- The
-noption chooses how many lines.
العربية
بداية الملف أو نهايته فقط
- للملفات الطويلة، قد ترغب غالباً برؤية جزء قصير منها:
- أمر
headيعرض الأسطر الأولى، وأمرtailيعرض الأسطر الأخيرة.
head -n 2 poem.txt
tail -n 1 poem.txt
- خيار
-nيحدد عدد الأسطر المراد عرضها.
English
Counting
wc(word count) measures a file. The most useful option is-lfor lines:
wc -wcounts words andwc -ccounts characters. Now try the tasks.
العربية
العد
- أمر
wc(word count) يقيس حجم ملف. الخيار الأكثر فائدة هو-lلعد الأسطر:
wc -l poem.txt
- أمر
wc -wيعد الكلمات وأمرwc -cيحسب الأحرف. الآن جرب المهام.
English
Common mistakes
catprints a whole file at once; uselessto scroll a large one.- Press Tab to complete a long file name.
العربية
أخطاء شائعة
catيطبع ملفًا بأكمله دفعة واحدة؛ استخدمlessلتصفح ملف كبير.- اضغط Tab لإكمال اسم ملف طويل تلقائياً.
Use cat to print the whole contents of poem.txt. · استخدم cat لطباعة محتويات poem.txt كاملة.
How many lines does the poem have? Use wc -l poem.txt to count them. · كم عدد أسطر القصيدة؟ استخدم wc -l poem.txt لعدّها.