WSL cat, echo, tail, grep
WSL cat, echo, tail, grep
1. cat
cat demo.html là in ra nội dung trong file demo.html.
cat demo.html test.html là in ra nội dung file demo.html và test.html.
cat demo.html test.html > concat.html là gom nội dung 2 file vào file concat.html (tạo và lưu file tạo thư mục hiện tại).
2. echo
echo 123 in 123 ra.
echo "Hello" in Hello ra.
echo "<h1>Hello</h1>" > echo.html
cat echo.html thì in nội dung echo.html.
echo "<h1>Hello</h1>" > echo.html
echo "<h1>Hello</h1>" > echo.html
> là ghi đè lên nội dung.
echo "<h1>Hello</h1>" >> echo.html là ghi thêm nội dung h1 vào file.
3. tail
tail demo.html là in 10 dòng cuối file demo.html.
tail -n 5 demo.html là in 5 dòng cuối file demo.html.
tail --help để xem hướng dẫn.
tail -f demo.html dùng để theo dõi file, dùng trong theo dõi file log.
4. grep
cat demo.html | grep 68 là in nội dung file demo.html với giá trị tìm kiếm là 68.
echo "Hello world" | grep world là in nội dung với giá trị tìm kiếm là world.