[Bash] View Files and Folders in Bash
Sometimes when working at the command line, it can be handy to view a file’s contents right in the terminal, or open a file with a certain application. We’ll learn how to view files in the terminal using cat
and less
and we’ll learn how to open them with open
.
View Files:
A good command to view file:
$ less package.json
It shows only the files content without previous commands, and we can use keyboard to control the content display.
To bottom:
$ Shift + g
To top:
$ g
It also enable search content inside file easily:
/mdx
Search for "mdx" inside the file
View Folder:
Sometime when you 'cd' into a folder by using command line, you also want to open the folder to see the files:
open .
It will opens the folder in current path.
You can also use 'open' to open a file by using default IDE:
open package.json
You can also open the folder by telling to using "Webstorm":
open . -a webstorm