Saving output to 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
Catching the output
- Normally a command's output appears on screen. The
>symbol redirects it into a file instead:
- Nothing prints — the text went into
greeting.txt. Read it back withcat greeting.txt.
العربية
التقاط المخرجات
- عادةً تظهر مخرجات الأمر على الشاشة. رمز
>يعيد توجيهها إلى ملف بدلاً من ذلك:
echo hello > greeting.txt
- لن يتم طباعة شيء — بل ذهب النص إلى
greeting.txt. اقرأه مرة أخرى باستخدامcat greeting.txt.
English
Replace vs add
>replaces the file's contents (or creates it if new).>>appends — it adds to the end, keeping what was there:
- Use
>>when you are building up a file, like a log.
العربية
الاستبدال مقابل الإضافة
>يستبدل محتويات الملف (أو ينشئه إذا كان جديداً).>>يضيف — فهو يضيف إلى النهاية مع الاحتفاظ بما كان موجوداً:
echo line one > notes.txt
echo line two >> notes.txt
- استخدم
>>عندما تقوم ببناء ملف تدريجياً، مثل سجل الأحداث.
English
Why this matters
- Saving output lets you keep results, build files from commands, and feed one program's output to another.
- ⚠️ Watch out:
>on an existing file erases it first. Use>>when you mean "add".
العربية
لماذا هذا مهم
- حفظ المخرجات يتيح لك الاحتفاظ بالنتائج، وبناء ملفات من الأوامر، وتزويد مخرجات برنامج واحد لبرنامج آخر.
- ⚠️ انتبه:
>على ملف موجود يحذفه أولاً. استخدم>>عندما تقصد "الإضافة".
English
Common mistakes
>overwrites a file;>>adds to the end.>on a file that already exists erases it first.
العربية
أخطاء شائعة
>يستبدل ملفاً؛>>يضيف إلى النهاية.>على ملف موجود مسبقاً يحذفه أولاً.
Send the output of echo into a file with >. Write hello into greeting.txt, then cat it back. · أرسل مخرجات echo إلى ملف باستخدام >. اكتب hello في greeting.txt، ثم catها مرة أخرى.
>> adds a line instead of replacing. Write first into log.txt, then append second, then show the file. · >> يضيف سطراً بدلاً من استبداله. اكتب first في log.txt، ثم أدرج second، ثم اعرض الملف.