Harness `seq` for Effortless Numbered Loops

Quick Tip

Harness `seq` for Effortless Numbered Loops

Challenge: You need to generate a sequence of numbers for use in a loop or to create multiple files with sequential names, but doing it manually is tedious.

The Solution: The `seq` command is your best friend for generating sequences of numbers.

seq 5 # Generates numbers from 1 to 5, each on a new line seq 2 5 # Generates numbers from 2 to 5 seq 10 -2 2 # Generates numbers from 10 down to 2, stepping by -2 

Why it works: `seq` is a simple command-line utility that generates a sequence of numbers according to the specified start, increment, and end values, making it incredibly useful for scripting and automation tasks.

Pro-Tip: Combine `seq` with `xargs` or brace expansion for powerful file creation or command execution loops. For example: touch file_$(seq -w 1 5).txt to create file_01.txt to file_05.txt.

Linux Tips & Tricks | © ngelinux.com | 5/3/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments