learnLinux MasteryText Processing Intro

// LINUX ROADMAP · Text Processing

Text Processing Intro

60m0 materialstodo

টেক্সট ডেটা ম্যানিপুলেট করতে grep, sed, awk, sort, uniq শিখুন

Core Concepts & Mental Model

Standard Linux syntax follows: command [options] [arguments], for example: ls -la /home/joy. Use the sticky terminal on the right to practice simultaneously.

Command Cards & Analysis

5 commands
#01grep— লাইনে খোঁজা
Concept

ফাইলের ভেতরে লাইনে লাইনে প্যাটার্ন খোঁজে।

When to Use

কনফিগে মান খুঁজতে, লগে এরর বাছতে, কোডে TODO দেখতে।

SYNTAX
grep "<pattern>" <file>
grep -r "<pattern>" <directory>
EXAMPLE
grep "error" notes.txt
grep -r "TODO" ~/projects
EXPECTED OUTPUT
line 12: error in config file
Important Note:

প্যাটার্নে স্পেস থাকলে কোট দিয়ে দেবেন। `grep` ছাড়া ফাইল খোঁজা অসম্ভব হয়।

#02sed 's/old/new/' file— sed 's/old/new/' file
Concept

Run command in terminal to test.

SYNTAX
sed 's/old/new/' file
EXAMPLE
sed 's/old/new/' file
EXPECTED OUTPUT
(no output returned)
#03awk '{print $1}' file— awk '{print $1}' file
Concept

Run command in terminal to test.

SYNTAX
awk '{print $1}' file
EXAMPLE
awk '{print $1}' file
EXPECTED OUTPUT
(no output returned)
#04sort— সাজানো
Concept

লাইনগুলো Alphabet/সংখ্যা অনুযায়ী সাজায়।

When to Use

লগ সাজাতে, ইউজার লিস্ট সাজাতে, ডিফারেন্স আগে প্রস্তুতি নিতে।

SYNTAX
sort <file>
sort -n <file>
sort -r <file>
EXAMPLE
sort notes.txt
sort -t: -k3 -n /etc/passwd
EXPECTED OUTPUT
apple
banana
orange
Important Note:

`-n` সংখ্যা, `-r` বিপরীত, `-t:` ডেলিমিটার, `-k3` কলাম।

#05uniq— ডুপ্লিকেট সরানো
Concept

পাশাপাশি একই লাইন একটাই রাখে।

When to Use

লগে একই এরর কতবার দেখতে, ডুপ্লিকেট সরাতে।

SYNTAX
sort <file> | uniq
uniq -c
EXAMPLE
cat notes.txt | sort | uniq
sort notes.txt | uniq -c
EXPECTED OUTPUT
3 error
      1 success
Important Note:

`uniq` শুধু পাশাপাশি সাজালেই কাজ করে — তাই আগে `sort` করতে হয়।

Curated reference links

My learning notes

টেক্সট ডেটা ম্যানিপুলেট করতে grep, sed, awk, sort, uniq শিখুন

joy@ubuntu: ~ (bash)
0/5
Targets:
joy@ubuntu:~$
grep pattern file
Tab autocomplete↑/↓ history