https://github.com/lurst/numbrs
:floppy_disk: See the line numbers of whathever it is that's going on in STDOUT
https://github.com/lurst/numbrs
Last synced: 17 days ago
JSON representation
:floppy_disk: See the line numbers of whathever it is that's going on in STDOUT
- Host: GitHub
- URL: https://github.com/lurst/numbrs
- Owner: LuRsT
- Created: 2013-09-19T07:36:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-02T17:29:43.000Z (almost 12 years ago)
- Last Synced: 2025-01-19T17:31:25.274Z (12 months ago)
- Language: Awk
- Homepage:
- Size: 215 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# numbrs
See the line numbers of whathever it is that's going on in `STDOUT` by piping
it to `numbrs`.
NOTE: I just found about the `nl` command thanks to
[deltaray](https://github.com/deltaray) on [#1](https://github.com/LuRsT/numbrs/issues/1), so this script can be replaced by
`nl -ba` which should come with your OS.
## Installation:
The only requirement for this script is `awk`, which, if you're using Linux, you
most certainly already have.
Just put the file in one of the many paths that your `$PATH` already has,
hopefully, you'll have write access to one of them to put the file there and
give it execution permission, basically this:
$ curl https://raw.github.com/LuRsT/numbrs/master/numbrs > ~/bin/numbrs
$ chmod +x ~/bin/numbrs
Note: This has the requirement of `~/bin` being in your `$PATH`
## Example usage:
### Number `ls` output:
$ ls -1
README.md
numbrs
$ ls -1 | numbrs
1 README.md
2 numbrs
### Number `grep` output:
$ grep "num" README.md | numbrs
1 numbrs
2 See the line numbers of whathever it is that's going on in STDOUT by piping it to `numbrs`.
3 cat numbrs | ./numbrs
4 numbrs
5 $ ls -1 | numbrs
6 2 numbrs
### Number `cat` output:
$ cat .git/config | numbrs
1 [core]
2 repositoryformatversion = 0
3 filemode = true
4 bare = false
5 logallrefupdates = true
6 [remote "origin"]
7 url = git@github.com:LuRsT/numbrs.git
8 fetch = +refs/heads/*:refs/remotes/origin/*
9 [branch "master"]
10 remote = origin
11 merge = refs/heads/master
An alternative to this is if you're doing it with a fixed number of lines (like
all of the examples above), you can just use `less -N`, however, if you want to
do that in a stream e.g. using `tail -F`, this script is better suited for
that.