🖥️seq
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the seq command with important options and switches using examples.
6 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗███████╗ ██████╗
# ██╔════╝██╔════╝██╔═══██╗
# ███████╗█████╗ ██║ ██║
# ╚════██║██╔══╝ ██║▄▄ ██║
# ███████║███████╗╚██████╔╝
# ╚══════╝╚══════╝ ╚══▀▀═╝
seq 20 | shuf
# Generate a random ordered list of 20 numbers. For example to determine order of presentation.
seq 1 1008 | awk '{if (2016%$1==0){print $0 "x" (2016/$1)}}'
# Or find another terminal resolution that equals 2016.
seq 100/\>awk '{s+=$0}END{print s}'
seq 100 | xargs -n1 -I{} date -d "+{} days" +%Y%m%d | xargs mkdir
# Make dated directories for next 100 days. Use date -v+{}d on BSD.
seq 100 | xargs -n1 -I{} date -d "+{} days" +%Y%m%d | xargs mkdir
# Make dated directories for next 100 days. Use date -v+{}d on BSD.
seq 100 | xargs -n1 -I{} date -d "+{} days" +%Y%m%d | xargs mkdir
# Make dated directories for next 100 days. Use date -v+{}d on BSD.
seq 100 | xargs -n1 -I{} date -d "+{} days" +%Y%m%d | xargs mkdir
# Make dated directories for next 100 days. Use date -v+{}d on BSD.
# Generate a sequence of numbers. for description type man seq
seq 12
# draw honeycomb
tput setaf 1 && tput rev && seq -ws "___|" 81|fold -69|tr "0-9" "_" && tput sgr0 # (brick wall)
seq -ws "\\__/" 99|fold -69|tr "0-9" " "
## Alternative one-liners:
Shuffle lines
seq 5 | shuf
# draw mesh
seq -s " \\_/" 256|tr -d "0-9"|fold -70
# Shuffle lines
seq 5 | shuf
# Explanation: shuf is part of the textutils package of GNU Core Utilities and should be available on most systems.
# Generate a sequence of numbers
echo {01..10}
# Explanation: This example will print:
01 02 03 04 05 06 07 08 09 10
# While the original one-liner is indeed IMHO the canonical way to loop over numbers, the brace expansion syntax of Bash 4.x has some kick-ass features such as correct padding of the number with leading zeros.
# Limitations: The zero-padding feature works only in Bash >=4.
## Related one-liners
# Generate a sequence of numbers
for ((i=1; i<=10; ++i)); do echo $i; done
# Explanation: This is similar to seq, but portable. seq does not exist in all systems and is not recommended today anymore. Other variations to emulate various uses with seq:
# seq 1 2 10
for ((i=1; i<=10; i+=2)); do echo $i; done
# seq -w 5 10
for ((i=5; i<=10; ++i)); do printf '%02d\n' $i; done
#Generate a sequence of numbers
for ((i=1; i<=10; ++i)); do echo $i; done
# Explanation:
#This is similar to seq, but portable. seq does not exist in all systems and is not recommended today anymore. Other variations to emulate various uses with seq:
# seq 1 2 10
for ((i=1; i<=10; i+=2)); do echo $i; done
# seq -w 5 10
for ((i=5; i<=10; ++i)); do printf '%02d\n' $i; done
## Alternative one-liners:
#Generate a sequence of numbers
echo {01..10}
# Explanation:
#This example will print:
01 02 03 04 05 06 07 08 09 10
#While the original one-liner is indeed IMHO the canonical way to loop over numbers, the brace expansion syntax of Bash 4.x has some kick-ass features such as correct padding of the number with leading zeros.
# Limitations:
#The zero-padding feature works only in Bash >=4.
#Generate a sequence of numbers
perl -e 'print "$_\n" for (1..10);'
# Explanation:
#Print the number with newline character which could be replaced by any char.
#Generate a sequence of numbers
for ((i=1; i<=10; ++i)); do echo $i; done
# Explanation:
#This is similar to seq, but portable. seq does not exist in all systems and is not recommended today anymore. Other variations to emulate various uses with seq:
# seq 1 2 10
for ((i=1; i<=10; i+=2)); do echo $i; done
# seq -w 5 10
for ((i=5; i<=10; ++i)); do printf '%02d\n' $i; done
## Alternative one-liners:
#Generate a sequence of numbers
echo {01..10}
# Explanation:
#This example will print:
01 02 03 04 05 06 07 08 09 10
#While the original one-liner is indeed IMHO the canonical way to loop over numbers, the brace expansion syntax of Bash 4.x has some kick-ass features such as correct padding of the number with leading zeros.
# Limitations:
#The zero-padding feature works only in Bash >=4.
#Generate a sequence of numbers
perl -e 'print "$_\n" for (1..10);'
# Explanation:
#Print the number with newline character which could be replaced by any char.
#Shuffle lines
... | perl -MList::Util -e 'print List::Util::shuffle <>'
# Explanation:
#Sorting lines is easy: everybody knows the sort command.
#But what if you want to do the other way around? The above perl one-liner does just that:
# -MList::Util load the List::Util module (as if doing use List::Util inside a Perl script)
# -e '...' execute Perl command
# print List::Util::shuffle <> call List::Util::shuffle for the lines coming from standard input, read by <>
#Another way would be sort -R if your version supports that (GNU, as opposed to BSD). In BSD systems you can install coreutils and try gsort -R instead. (For eample on OSX, using MacPorts: sudo port install coreutils.)
## Alternative one-liners:
#Shuffle lines
seq 5 | shuf
# Explanation:
shuf is part of the textutils package of GNU Core Utilities and should be available on most systems.
#huffle lines
... | perl -MList::Util=shuffle -e 'print shuffle <>;'
# Explanation:
#Sorting lines is easy: everybody knows the sort command.
#But what if you want to do the other way around? The above perl one-liner does just that:
# -MList::Util=shuffle load the shuffle function from the List::Util package
# -e '...' execute Perl command
# If you need dates relative to today you can do (note the absence of a for loop):
seq -f "%g day" -7 2 7 | date --file - +%F
2019-06-17
2019-06-19
2019-06-21
2019-06-23
2019-06-25
2019-06-27
2019-06-29
2019-07-01
# shell bash iterate number range with for loop
seq 10 20
#==============================##==============================#
# CMD SEQ - sequence
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command seq in a clear format. This allows users to quickly access the needed information for seq without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for seq are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.