Show 1 to N on the terminal
I am looking for simple thing just, foo 8 will shows this:
1
2
3
4
5
6
7
8
PS: I am looking just for command line. I know how to create that by using for
on the bash
Solution 1:
To print a sequence of number the command 'seq' is your friend
seq 8
Solution 2:
{1..8}
will give you a simple argument range in Bash.
If you need that line by line, I'd suggest feeding that to something like printf:
$ printf '%d\n' {1..8}
1
2
3
4
5
6
7
8
Solution 3:
You can also use echo
command with brace expansion
echo -e "\n"{1..8}
1
2
3
4
5
6
7
8
If you don't want the initial newline, you can use one of the below commands.
echo -e "\n"{1..8}|tail -n8
echo -e "\n"{1..8}|grep .
echo -e "\n"{1..8}|grep [0-9]
echo -e "\n"{1..8}|sed 1d