Saving output to files · Menyimpan output ke file
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Halaman ini memerlukan browser terbaru (dengan dukungan SharedArrayBuffer). Silakan perbarui Chrome, Edge, Firefox, atau Safari ke versi terbaru.
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.
Bahasa Indonesia
Menangkap output
- Biasanya output sebuah perintah muncul di layar. Simbol
>mengalihkannya ke dalam file sebagai gantinya:
echo hello > greeting.txt
- Tidak ada yang tercetak — teks masuk ke dalam
greeting.txt. Bacalah kembali dengancat 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.
Bahasa Indonesia
Ganti vs tambahkan
>mengganti isi file (atau membuatnya jika baru).>>menambahkan — ia menambah di akhir, menjaga apa yang sudah ada:
echo line one > notes.txt
echo line two >> notes.txt
- Gunakan
>>ketika Anda sedang membangun file, seperti log.
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".
Bahasa Indonesia
Mengapa ini penting
- Menyimpan output memungkinkan Anda menyimpan hasil, membuat file dari perintah, dan mengalirkan output satu program ke program lain.
- ⚠️ Waspadai:
>pada file yang sudah ada mengosongkannya terlebih dahulu. Gunakan>>ketika maksud Anda "tambah".
English
Common mistakes
>overwrites a file;>>adds to the end.>on a file that already exists erases it first.
Bahasa Indonesia
Kesalahan umum
>menimpa file;>>menambahkan ke bagian akhir.>pada file yang sudah ada akan mengosongkannya terlebih dahulu.
Send the output of echo into a file with >. Write hello into greeting.txt, then cat it back. · Kirim output dari echo ke dalam file dengan >. Tulis hello ke dalam greeting.txt, lalu kembalikan cat itu.
>> adds a line instead of replacing. Write first into log.txt, then append second, then show the file. · >> menambahkan baris alih-alih mengganti. Tulis first ke dalam log.txt, lalu append second, lalu tampilkan file.