Bash Tutorials

This page lists every Bash tutorial on Collecting Wisdom.

Bash: How to Replace Text in String
Bash: How to Replace Special Characters in String
Bash: How to Replace Multiple Characters in String
Bash: How to Replace Specific Line in File
Bash: How to Replace Newline with Comma
Bash: How to Replace Space with Underscore
Bash: How to Replace Dash with Underscore
Bash: How to Rename Extension of Multiple Files
Bash: How to Replace All Occurrences of String in File
Bash: How to Replace Specific Text in Multiple Files
Bash: How to Replace Line in File By Line Number
Bash: How to Find Line Number of String in a File
Bash: How to Read CSV File and Skip First Line
Bash: How to Read Columns from CSV File into Arrays
Bash: How to Extract Specific Columns from CSV File
Bash: How to Extract the First and Last Column from File
Bash: How to Extract Text Between Two Strings
Bash: How to Extract Domain Name from URL
Bash: How to Extract String from Brackets
Bash: How to Extract Date from String
Bash: How to Extract Substring After Specific Character
Bash: How to Extract Substring Before Specific Character
Bash: How to Convert First Character in Variable to Uppercase
Bash: How to Align Columns in Output
Bash: How to Get Month Name
Bash: How to Get Day of Week
Bash: How to Get Last Day of Month
Bash: How to Get the Previous Month
Bash: How to Get the Next Month
Bash: How to Check if Date is a Weekend
Bash: How to Add and Subtract Days from a Date
Bash: How to Loop Over Tuples
Bash: How to Iterate Over Two Arrays at Once
Bash: How to Concatenate Arrays
Bash: How to Delete Lines from One File that Are in Another File
Bash: How to Delete Duplicate Lines in File
Bash: How to Delete All Files with Specific Extension
Bash: How to Delete All Files Whose Filename Contains String
Bash: How to Delete All Files with Specific Prefix
Bash: How to Delete All Files Without an Extension
Bash: How to Delete All Files Except Specific One
Bash: How to Delete All Files in Directory
Bash: How to Delete All Empty Lines in File
Bash: How to Delete Files Older than X Hours
Bash: How to Delete Files Older than X Days
Bash: How to Delete Directories Older than X Days
Bash: How to Create Multiple Files at Once
Bash: How to Check if File is Older than 1 Hour
Bash: How to List All Files in Folder by Size
Bash: How to Find First Folder Name that Contains String
Bash: How to Sort Directories by Size
Bash: How to Get Total Size of List of Files
Bash: How to Find the Largest File in a Directory
Bash: How to Add Timestamp to a Filename
Bash: How to Increment a Date
Bash: How to Find Files Newer than Specific Date or Time
Bash: How to List All Files in Folder Without Extension
Bash: How to List All Files Matching a Specific Pattern
Bash: How to List All Files Not Matching a Pattern
Bash: How to Find Newest File Matching a Pattern
Bash: How to List All Files in Folder by Date
Bash: How to Find All Files that Were Created Today
Bash: How to Find Files that Have Been Changed in Last 24 Hours
Bash: How to Find Files that Exist in One Directory But Not in Another
Bash: How to Add Suffix to All Files in Directory
Bash: How to Add Prefix to All Files in Directory
Bash: How to Transpose a File
Bash: How to Read File from Line X to End of File
Bash: How to Count Number of Unique Lines in File
Bash: How to Count Number of Lines in Each File in Directory
Bash: How to Count Number of Characters in String
Bash: How to Count Number of Columns in File
Bash: How to Count Number of Words in String
Bash: How to Count Number of Characters in Each Line of File
Bash: How to Count Number of Files Matching a Pattern
Bash: How to Count Number of Files in Each Directory
Bash: How to Count Number of Folders in a Directory
Bash: How to Count Number of Blank Lines in File
Bash: How to Group By and Count Lines
Bash: How to Get the Nth Word in a String
Bash: How to Calculate Frequency of Each Word in File
Bash: How to Calculate the Average of a Column
Bash: How to Find Minimum and Maximum Value of Column
Bash: How to Copy an Array
Bash: How to Get the Index of an Item in Array
Bash: How to Find Minimum and Maximum Values in Array
Bash: How to Get Unique Values from Array
Bash: How to Round Numbers to 2 Decimal Places
Bash: How to Calculate Ceiling of a Division Result
Bash: How to Print Specific Range of Lines from File
Bash: How to Check if Number is Within a Range
Bash: How to Check if Number is Even or Odd
Bash: How to Check if Number is Divisible by Another Number
Bash: How to Check if String Contains Substring
Bash: How to Check if String Starts with Specific Value
Bash: How to Check if String Ends with Specific Value
Bash: How to Check if File is Empty
Bash: How to Check if File Size is Greater than Zero
Bash: How to Check if File Contains Specific String
Bash: How to Find Common Lines in Two Files
Bash: How to Find All Files that Start with Specific Pattern
Bash: How to Find All Files that End with Number
Bash: How to Compare Two Files
Bash: How to Compare Dates
Bash: How to Compare a String with a Number
Bash: How to Find the Difference Between Two Arrays
Bash: How to Perform Case-Insensitive Comparison of Strings
Bash: How to Calculate Date Difference
Bash: How to Convert Epoch to Date
Bash: How to Convert Datetime to Epoch
Bash: How to Get Time Since File was Last Modified in Seconds
Bash: How to Use ‘cut’ with Multiple Spaces
Bash: How to Find Duplicate Lines in File
Bash: How to Check if String Has Spaces
Bash: How to Insert Text at the Beginning of File
Bash: How to Add Quotes to Each Line in a File
Bash: How to Add Text to Beginning of Each Line in File
Bash: How to Increment a Version Number
Bash: How to Sort Strings with Numbers
Bash: How to Sort by Specific Column in File
Bash: How to Sort File by Multiple Columns
Bash: How to Sort by Last Column in File
Bash: How to Sort a File by Line Length
Bash: How to Sort a File In-Place
Bash: How to Sort Lines in File and Ignore First Line
Bash: How to Print the Longest Line in a File
Bash: How to Extract Numbers from Filename
Bash: How to Display Both Head and Tail of File
Bash: How to Extract First Number from a String
Bash: How to Extract Last Number from a String
Bash: How to Get First N Characters from String
Bash: How to Get Last N Characters from String
Bash: How to Remove Non-Numeric Characters from String
Bash: How to Remove Specific Characters from String
Bash: How to Remove Last N Characters from String
Bash: How to Remove First Character from String
Bash: How to Remove Specific Characters from Filenames
Bash: How to Repeat a Character N Times
Bash: How to Check if Variable Exists in a List
Bash: How to Join Elements from Array into Delimited String
Bash: How to Add String to Each Element in an Array
Bash: How to Iterate Over Associative Array
Bash: How to Sort an Associative Array
Bash: How to Split a String into an Array
Bash: How to Split a String Using Multiple Delimiters
Bash: How to Split a String into Multiple Variables
Bash: How to Split a String and Get Last Element
Bash: How to Split Text File into Multiple Files
Bash: Split File into Multiple Files Based on Column Value
Bash: How to Find the Intersection of Two Arrays
Bash: How to Select Random Lines from a File
Bash: How to Select Random Element from an Array
Bash: How to Select Random Files from Directory
Bash: How to Generate Random Number in Range
Bash: How to Generate a Sequence of Numbers
Bash: How to Extract Directory from a File Path
Bash: How to Extract Filename from a Path
Bash: How to Extract Filename Without Extension from Path
Bash: How to Use ls Command to List Files with Full Path
Bash: How to Check if File Has Specific File Extension
Bash: How to Add Files Extension to All Files
Bash: How to Check if Specific File Type Exists in Directory
Bash: How to Copy All Files in Directory to Another Directory
Bash: How to Copy Multiple Specific Files from One Folder to Another
Bash: How to Copy All Files with Specific Extension from All Subdirectories
Bash: How to Copy All Files Except One
Bash: How to Copy a File to Multiple Directories
Bash: How to Copy and Rename a File
Bash: How to Rename All Files to Lowercase
Bash: How to Rename All Files to Uppercase
Bash: How to Rename Files in Folder to Sequential Numbers
Bash: How to Get First Word of a String
Bash: How to Get Last Word of a String
Bash: How to Get the Last Line of a File
Bash: How to Convert String to Integer
Bash: How to Convert String to Date
Bash: How to Convert Timestamp to Date
Bash: How to Create a Timestamp Variable
Bash: How to Format a DateTime
Bash: How to Get Time in Milliseconds
Bash: How to Convert Seconds to Hours, Minutes, Seconds
Bash: How to Read Lines of File into Array
Bash: How to Read Filenames into an Array
Bash: How to Slice an Array
Bash: How to Save Results of “find” Command to Array
Bash: How to Pad Numbers with Leading Zeros
Bash: How to Add a newline to End of a File
Bash: How to Remove Last Element from Array
Bash: How to Remove newline from String
Bash: How to Remove Prefix from a String
Bash: How to Remove Prefix from All Filenames
Bash: How to Remove Last Character from String
Bash: How to Remove Spaces from String
Bash: How to Remove Leading Zeros from a Variable
Bash: How to Remove Specific Columns from a File
Bash: How to Remove All Whitespaces from File
Bash: How to Trim Leading Whitespace from a Variable
Bash: How to Trim Trailing Whitespace from a Variable
Bash: How to Remove Only Double Empty Lines in File
Bash: How to Remove First Word from Each Line in File
Bash: How to Remove First and Last Characters from String
Bash: How to Remove First Column from a File
Bash: How to Remove First and Last Line from a File
Bash: How to Add Suffix to Each Line in File
Bash: How to Reverse the Words in Each Line of a File
Bash: How to Escape Dollar Signs
Bash: How to Filter CSV File Based on Column Value
Bash: How to Filter for Lines in File that Start with Specific String
Bash: How to Filter for Rows where Column is Not Empty
Bash: How to Use find -exec with grep
Bash: How to Use find Command and Exclude Specific Directory
Bash: How to Find All Files with Specific Extension
Bash: How to Find All Empty Directories
Bash: How to Use Echo to Output a Multi-line String
Bash: How to Echo All Values in an Array
Bash: How to Replace Patterns Using Regex
Bash: How to Use Regex with “OR” to Match Multiple Patterns
Bash: How to Use Regex to Match Digits
Bash: How to Append Values to Array
Bash: How to Concatenate Multiple Files into One File
Bash: How to Merge Multiple CSV Files into One File
Bash: How to Swap Two Columns in a File

sed

The sed stream editor can be used to perform various operations on text streams and files. Below is a list of each sed tutorial available on Collecting Wisdom:

How to Use sed to Replace newline with Comma
How to Use sed to Replace newline with space
How to Use sed to Replace All Occurrences of Pattern
How to Use sed to Replace All Text Before Match
How to Use sed to Replace All Text After Match
How to Use sed to Replace Only the First Occurrence in a File
How to Use sed to Replace Last Occurrence of Character in String
How to Use sed to Replace Tab Characters
How to Use sed to Replace Path with Another Path
How to Use sed to Replace First Line in a File
How to Use sed to Replace All Backslashes with Forward Slashes
How to Use sed to Replace Multiple Strings
How to Use sed to Replace Multiple Spaces with Single Space
How to Use sed to Replace Multiple Empty Lines with One Empty Line
How to Use sed to Replace String Between Two Patterns
How to Use sed to Replace Spaces with Commas
How to Use sed to Replace Last Line Matching Pattern
How to Use sed to Replace nth Occurrence of Pattern
How to Use sed to Replace Exact Match
How to Use sed to Replace Brackets
How to Use OR Operator in sed Regex
How to Use Case-Insensitive Search and Replace in sed
How to Use sed to Extract All Lines Containing a Pattern
How to Use sed to Extract Numbers from a String
How to Use sed to Delete All Lines Containing Specific String
How to Use sed to Delete All Empty Lines in File
How to Use sed to Delete Specific Line Numbers from File
How to Use sed to Delete First n Lines of File
How to Use sed to Delete Last n Lines of File
How to Use sed to Delete All Lines Starting with Specific Pattern
How to Use sed to Delete All Lines that Do Not Match Pattern
How to Use sed to Delete n Lines Following a Pattern
How to Use sed to Delete All Lines After Match
How to Use sed to Remove all Double Quotes from File
How to Use sed to Remove First n Characters of Line
How to Use sed to Remove Last n Characters of Line
How to Use sed to Remove a Substring
How to Use sed to Remove Trailing Whitespaces in File
How to Use sed to Remove the Last Character of a File
How to Use sed to Remove Leading Whitespaces in File
How to Use sed to Remove Trailing newlines from File
How to Use sed to Remove Non-Alphanumeric Characters
How to Use sed to Remove Every Other Line in File
How to Use sed to Insert a Line After Match
How to Use sed to Insert a Tab
How to Use sed to Insert Line at Specific Line Number
How to Use sed to Insert Line at Top of File
How to Use sed to Insert Multiple Lines After Match
How to Use sed to Insert Character at Beginning of Lines in File
How to Use sed to Insert Line with Leading Spaces
How to Use sed to Insert String After Every N Lines
How to Use sed to Split String Based on Delimiter
How to Use sed to Convert All Characters to Lowercase
How to Use sed to Convert First Letter of Word to Uppercase
How to Use sed to Print Out Line Numbers
How to Use sed to Print Specific Lines in File
How to Use sed to Print Every nth Line of File
How to Use sed to Print All Lines Between Two Patterns
How to Use sed to Print All Lines After Line with Match
How to Use sed to Print First n Characters of Line
How to Use sed to Apply Changes to Multiple Files
How to Use sed to Append Line to End of a File
How to Use sed to Append Text at End of Each Line
How to Use sed to Append Text to End of Each Line Matching Pattern
How to Use sed to Add Comma to End of Every Line in File
How to Use sed to Insert Empty Line in a File
How to Use sed to Insert Character at Specific Position
How to Use sed to Merge Every Two Lines in File
How to Escape Single Quotes in sed
How to Use sed to Rename Multiple Files
How to Use sed to Convert Multiple Lines into Comma Separated Line
How to Use sed to Comment Out Lines that Match Pattern
How to Use sed to Uncomment Lines Containing Pattern

awk

In Linux, awk is a scripting language that can be used to modify files in a variety of ways. Below is a list of each awk tutorial available on Collecting Wisdom:

How to Use awk to Replace newline with Space
How to Use awk to Replace All Occurrences of String in File
How to Use awk to Extract Substring
How to Use awk to Extract Specific Columns from File
How to Use Multiple Delimiters in awk
How to Use awk to Print First Column of File
How to Use awk to Print Last Column of File
How to Use awk to Print a Range of Columns
How to Use awk to Print All Fields Except First Field
How to Use awk to Print Last Line of a File
How to Use awk to Print Double Quotes in Output
How to Use awk to Print Rows Where Column Equals Value
How to Use awk to Print All Columns After Specific Number
How to Use awk to Print Out Line Numbers
How to Use awk to Sum the Values in a Column
How to Use awk to Group by and Sum Column Values
How to Use awk to Count Number of Occurrences of Word
How to Use awk to Count Unique Values in Column
How to Skip First Line in awk
How to Skip Empty Lines When Using awk
How to Use awk to Delete All Lines Matching a Pattern

grep

The grep command in Linux is used for searching and matching text patterns in files. Below is a list of each grep tutorial available on Collecting Wisdom:

How to Use grep to Get Line Number of Match
How to Use grep to List All Files Containing Specific String
How to Use grep to Extract URL from File
How to Use grep to Extract IP Addresses from File
How to Use grep to Extract Last Occurrence in File
How to Use grep with Case-Insensitive Matching
How to Use grep to Count All Occurrences of String per File
How to Use grep and Exclude Specific Directories
How to Use grep and Exclude Specific Files
How to Exclude a Pattern with grep
How to Exclude Multiple Patterns with grep
How to Use grep and Only Print Matching Pattern
How to Use grep to Only Print Second Match
How to Use grep to Find Lines that Exceed Certain Length