Here are some simple and useful commands-
file – check type of file
Check the type of file using the ‘file’ command. You will get the file type and also some additional information based on the file type.
$ file abc_SVG_20kB.svg
abc_SVG_20kB.svg: SVG Scalable Vector Graphics image
$ file demo.mp4
demo.mp4: ISO Media, MP4 v2 [ISO 14496-14]
$ file first_conf.json
first_conf.json: JSON data
$ file sample1.gif
sample1.gif: GIF image data, version 89a, 1900 x 1267
$ file test_AVI_480_750kB.avi
test_AVI_480_750kB.avi: RIFF (little-endian) data, AVI, 480 x 270, 30.00 fps, video: H.264 H.264 X.264 or H.264, audio: (stereo, 48000 Hz)
$ file zip_201.zip
zip_201.zip: Zip archive data, at least v1.0 to extract, compression method=store
Bashless – read file content
The simplest way to read the file content is by using “less” command. This will give us the content we can read on the screen, and then we can go to the next content.
# use "less" and then the file name, like below
$ less first_conf.json
# you will see the content here
# Press Enter to read the next(or use options mentioned below)
# Use 'q' to quite
BashWhen you are presented with the next, you see a colon at the bottom of the screen. The output is continuous, and you need to know the shortcuts to navigate through the result.
Here are the options that we can use for the less command, after it shows the first set of content-
Command or Key | Usage | Alternative key or command |
---|---|---|
space | One page forward | Page Down key |
b | One page backward | Page Up key |
Up arrow | One line up | |
Down arrow | One line down | Enter |
g | Go to the start of the file | 1G |
G | Go to the end of the file | |
/search_term | Search for the “search_term”(use your actual search term here) | |
n | Go to the next occurrence of the “search_term”, which was initiated by “/search_term”. | |
h | Help options | |
q | Quit the “less” command output. |