Linux filters commands 🐧


This file provides some Linux commands for text processing, searching, and file manipulation. I did this file as notes for myself and I think whether you’re a beginner or an experienced Linux user,this sort of cheatsheet might help you as well .

Grep

Using grep command in linux

grep [...options] pattern [file..]

Search for text in a file:

grep hello file.txt

Search for text in a case-insensitive manner:

grep -i hello file.txt

Recursively search for text in all files under each directory:

grep -iR hello file.txt

look for a pattern in all files in the current directory

grep  hello *

Less

The ‘less’ command is a file viewer for Linux.

less  [file...]
press enter to scroll down by line

Tail

The ‘tail’ command outputs the last part of files.

tail [...File]

Use the ‘-f’ option to watch the appended data in real-time (useful for reading logs).

tail -f [...File]

Cut

The ‘cut’ command in Linux is used to extract sections from lines of files.

Extract the first column (fields) from a CSV file (assuming comma as the delimiter):

cut -d',' -f1 input.csv