diff --git a/README.md b/README.md index fb53d07..478314a 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ smart people at [Hashrocket](http://hashrocket.com/). ### zsh +- [Cat A File With Line Numbers](zsh/cat-a-file-with-line-numbers.md) - [Clear The Screen](zsh/clear-the-screen.md) - [Create A File Descriptor with Process Substitution](zsh/create-a-file-descriptor-with-process-substitution.md) - [Killing A Frozen SSH Session](zsh/killing-a-frozen-ssh-session.md) diff --git a/zsh/cat-a-file-with-line-numbers.md b/zsh/cat-a-file-with-line-numbers.md new file mode 100644 index 0000000..e929ee4 --- /dev/null +++ b/zsh/cat-a-file-with-line-numbers.md @@ -0,0 +1,27 @@ +# Cat A File With Line Numbers + +You can quickly view a file using `cat` + +``` +$ cat Gemfile +source 'https://rubygems.org' + + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.2.0' +# Use postgresql as the database for Active Record +gem 'pg' +``` + +With the `-n` flag I can view that file with line numbers + +``` +$ cat -n Gemfile + 1 source 'https://rubygems.org' + 2 + 3 + 4 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' + 5 gem 'rails', '4.2.0' + 6 # Use postgresql as the database for Active Record + 7 gem 'pg' +```