Sunday, 28 August 2016

Unix bash cheat sheet


Getting the current directory:

$ pwd



To find some executable:


$ where perl
C:\cygwin64\bin\perl.exe




$ which perl
/usr/bin/perl



Viewing the whole content of the file:


$ cat /bin/man2html



Viewing only the first line of the file:

$ head -n 1 file.txt



Viewing only the last line of the file:

$ tail -n 1 file.txt



Editing file:

$ vi /bin/man2html



Initially, vi opens in command mode.

i - to enter edit (insert) mode
ESC - to exit edit mode
:wq - write and quit
:q! - quit without saving changes

Post a Comment