Let's think about it this way for a second
A pipe (|) sends one command's output directly into the next command's input — just like connecting a water pipe. ls -la | grep txt sends ls's output to grep, which then catches only the lines containing 'txt'. Redirection sends output to a file instead of the terminal — > overwrites the file (deletes the old content and writes fresh), while >> appends to the end of the file (adds on without deleting). < tells a command to read data from a file as its input.
Let's connect this to a real-world scenario
ls -la > filelist.txt saves ls's output into filelist.txt instead of showing it on screen. echo "log entry" >> app.log adds a new line without deleting the log file's old content — you should always use >> for log files, since using > by mistake can wipe out your entire log history. A command chain like ps aux | grep python | wc -l does three jobs in a single line: list the processes, catch the lines containing python, and count how many lines there are in total.
Let's try it together in the terminal
ls -la | grep txt
ps aux | grep python
echo "first line" > log.txt
echo "second line" >> log.txt
cat log.txt # ၂ ကြောင်းစလုံးမြင်ရမည်The log.txt file will contain two lines: first line and second line.5-Minute Try-It
Run ls -la | grep .txt in your practice folder and write down what the results show. Then try out the difference between > and >> yourself using echo.
A Quick Word of Caution
If you accidentally use > on an important file, the entire contents can vanish instantly — and there's no Recycle Bin to save you, just so you know.