মূল বিষয়বস্তুতে যান
kitlocal.dev

Text CLI (grep / sed / awk) চিটশিট

লোকালি চলে

১০০% আপনার ব্রাউজারে প্রসেস হয়। ইনপুট ও আউটপুট কখনো আপনার ডিভাইস ছেড়ে যায় না।

বাস্তব পাইপলাইনসহ Unix টেক্সট প্রসেসিং কমান্ড: GNU grep/ripgrep সার্চিং, sed স্ট্রিম এডিটিং, awk ফিল্ড ও অ্যাগ্রিগেশন, সাথে cut, sort, uniq ও tr।

যেভাবে কাজ করে

Unix text tools act like stream filters: each tool reads lines from files or stdin, does one small job (search, slice columns, replace, count, sort) and writes lines to stdout so you can snap them together with `|`.

সারভাইভাল কিট

যে কয়েকটি কমান্ড সবার আগে শিখতে হবে।

৪১টি কমান্ড

কীবোর্ড শর্টকাট/সার্চে ফোকাস করুনJKনির্বাচন সরানCনির্বাচিতটি কপি করুনFনির্বাচিতটি বুকমার্ক করুনEscসার্চ মুছুন

Search lines (grep)

grep prints lines matching a pattern. Add -n for line numbers, -i for case-insensitive and -E for extended regex.

অফিসিয়াল ডকুমেন্টেশন: grep usage
  • অপরিহার্য

    Search recursively and print file paths and line numbers.

    grep -rn "<pattern>" <dir>

    কমান্ড তৈরি করুন

    grep -rn "<pattern>" <dir>

    মানগুলো ঠিক যেভাবে টাইপ করা হয়েছে সেভাবেই বসানো হয়। স্পেস বা বিশেষ অক্ষর থাকলে নিজে কোট দিয়ে নিন।

    কখন ব্যবহার করবেন

    Find every occurrence of a function, error code or config key across a directory tree.

    বিশ্লেষণ

    -r
    recurse into subdirectories
    -n
    prefix matches with 1-based line numbers
    <pattern>
    search regex or text
    <dir>
    directory to search (use `.` for current)

    উদাহরণ

    printf "200 GET /api\n500 POST /pay\n200 GET /api\n404 GET /old\n" | grep -n "GET"

    ফলাফল

    1:200 GET /api
    3:200 GET /api
    4:404 GET /old

    বিকল্প উপায়

    • rg "<pattern>" (ripgrep, skips .gitignore automatically)

    আরও দেখুন

Transform text streams (sed)

sed edits lines on the fly. Test without `-i` first so you preview changes on stdout before modifying files.

অফিসিয়াল ডকুমেন্টেশন: sed commands

Process columns & aggregate (awk)

awk splits every line into fields ($1, $2, ...) automatically, running `{ action }` whenever `condition` is true.

অফিসিয়াল ডকুমেন্টেশন: GNU Awk User Guide

Sort, count, cut & translate

Fast single-purpose coreutils for frequency counts, column slicing and character cleanup.

অফিসিয়াল ডকুমেন্টেশন: Operating on sorted files

Find files & batch commands (find, xargs)

Locate files by name, size or age and pass them safely to downstream commands using NUL delimiters.

অফিসিয়াল ডকুমেন্টেশন: GNU Findutils Manual

KitLocal টুলে এটি চেষ্টা করে দেখুন

শব্দকোষ
stdin / stdout
Standard input and output streams wired together by pipes (`|`).
ERE (-E)
Extended Regular Expressions: `+`, `?`, `|`, `()` work without extra backslashes.
Field ($1, $NF)
In awk, columns split by whitespace (or `-F`): `$0` is the whole line, `$NF` is the last column.
NUL delimiter (-0)
Separating paths with `\0` instead of newlines so spaces and quotes never break pipelines.

১৫ নভে, ২০২৬ তারিখে যাচাইকৃত · GNU grep 3.12 / sed 4.9 / gawk 5.3-এর বিপরীতে যাচাইকৃত

উৎস: GNU Coreutils Manual · GNU grep Manual · GNU sed Manual · GNU Awk Manual

অ্যাঙ্গেল ব্র্যাকেটের ভেতরের অংশগুলো আপনার নিজস্ব মান দিয়ে প্রতিস্থাপন করুন। কমান্ডগুলো অফিসিয়াল ডকুমেন্টেশন থেকে নেওয়া হয়েছে এবং প্রদর্শিত সংস্করণে উদাহরণগুলো পরীক্ষা করা হয়েছে।