--- layout: page author: Domenico Votta category-page: advanced category-title: Advanced commands tags: number lines count title: nl ---
The nl
is a command that permits to number the lines.
Through some flags you can decide how to filter this command.
We have a file named example.txt
that contains 5 elements, to test this command:
{% highlight bash linenos %}
Car
Computer
Robot
Smartphone
Videogame
{% endhighlight %}
The syntax command is:
nl [flags][file]
nl example.txt 1 Car 2 Computer 3 Robot 4 Smartphone 5 VideogameHow you can see the command has numbered the lines.
nl -b p^[cv] example.txt 1 Car 2 Computer 3 Videogame Robot Smartphone
p^[cv]
says to nl to number only the lines that start with c and v.
nl -bn example.txt Car Computer Videogame Robot Smartphone
nl -s= example.txt 1=Car 2=Computer 3=Videogame 4=Robot 5=Smartphone