less command I want to definitely remember this [linux command]

Click here for the video (Click the image to go to youtube. 2020/06/18 8:00 release) How to use the less command. When it's just a cat [linux command] com / watch? v = nl8M2CWghOU)

Brief explanation

What is less?

Display the contents of the file. It can be displayed with cat and more, Basic less is used most.

Use Case

-When you want to see the contents of a file that does not fit on the screen. -When you want to take a closer look at the standard output of grep and other commands.

syntax

less option filename

option

-N: Line number display -m: Progress display

Basic operation (I want to remember for sure)

q: End g: Move to the top of the file G: Move to end of file SPACE: Advance one screen b: 1 screen back /: Search n → forward, N → back F: Display after inputting a file (End with ctrl + c. You can also use "tail -f")

Sample command

less sample.tsv less -Nm sample.tsv grep a sample.txt | less

Actual operation

When you hit it normally

less sample.tsv
file_name       category_id
train_0.jpg     4
train_1.jpg     21
train_2.jpg     16
train_3.jpg     20
train_4.jpg     24
train_5.jpg     23
train_6.jpg     4
train_7.jpg     23
train_8.jpg     5
train_9.jpg     20
train_10.jpg    20
train_11.jpg    11
train_12.jpg    8

-N option

less -N sample.tsv

Line number at the beginning

      1 file_name       category_id
      2 train_0.jpg     4
      3 train_1.jpg     21
      4 train_2.jpg     16
      5 train_3.jpg     20
      6 train_4.jpg     24
      7 train_5.jpg     23
      8 train_6.jpg     4
      9 train_7.jpg     23
     10 train_8.jpg     5
     11 train_9.jpg     20
     12 train_10.jpg    20
     13 train_11.jpg    11
     14 train_12.jpg    8
     15 train_13.jpg    12
     16 train_14.jpg    9

-m option

less -m sample.tsv

At the bottom, where you are now is displayed in%.

train_320.jpg   21
train_321.jpg   14
train_322.jpg   18
train_323.jpg   17
train_324.jpg   15
train_325.jpg   3
train_326.jpg   6
train_327.jpg   2
train_328.jpg   0
train_329.jpg   5
train_330.jpg   22
train_331.jpg   7
train_332.jpg   2
train_333.jpg   13
train_334.jpg   16
31%

/ Search by word

Display less,

less sample.tsv

Search at the bottom / 24. Twenty-four locations are highlighted. (If it is below, it cannot be colored, so it is displayed as it is.)

    239 train_237.jpg   16
    240 train_238.jpg   24
    241 train_239.jpg   2
    242 train_240.jpg   17
    243 train_241.jpg   13
    244 train_242.jpg   15
    245 train_243.jpg   16
    246 train_244.jpg   6
    247 train_245.jpg   2
    248 train_246.jpg   24
    249 train_247.jpg   13
    250 train_248.jpg   14
    251 train_249.jpg   23
    252 train_250.jpg   17
    253 train_251.jpg   14
    254 train_252.jpg   10
    255 train_253.jpg   14
    256 train_254.jpg   21
    257 train_255.jpg   15
/24

Finally

There is no point in writing the basic operation, so please check it in the video.

Recommended Posts

less command I want to definitely remember this [linux command]
I want to know how LINUX works!
I want to use Linux on mac
I want to log file I / O on Linux
Linux commands to remember
I want to be notified when the command operation is completed on linux!
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
I want to automate ssh using the expect command!
(Remember quickly) How to use the LINUX command line
I want to use Linux commands at the command prompt! Use Linux commands at the command prompt instead of Git Bash
I want to solve Sudoku (Sudoku)
I tried to reintroduce Linux
I want to automate ssh using the expect command! part2
I want to start a jupyter environment with one command
[Linux] I want to know the date when the user logged in
I want to understand systemd roughly
[linux] kill command to kill the process
I want to connect remotely to another computer, and the nautilus command
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to leave an arbitrary command in the command history of Shell
I want to pin Spyder to the taskbar
I want to output to the console coolly
I tried to summarize the umask command
I want to print in a comprehension
I want to scrape them all together.
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to use jar from python
[Linux] How to use the echo command
I want to build a Python environment
I want to pip install with PythonAnywhere
How to use the Linux grep command
I want to analyze logs with Python
I want to play with aws with python
I want to use IPython Qt Console
[Linux convenient command] Try to insert vivid
I want to display the progress bar
I want to make an automation program!
I want to embed Matplotlib in PySimpleGUI
I want to handle the rhyme part2
I want to develop Android apps on Android
I want CAPTCHA to say HIWAI words
I want to handle the rhyme part5
I want to handle the rhyme part4
3 best ways to use the less command
Linux command # 3
Linux command # 5
[Linux] You do not have root privileges. But I want to yum install.
I want to realize something like AutoHotkey with AutoKey on Ubuntu (Kali Linux)
I want to make matplotlib a dark theme
I want to connect to PostgreSQL from various languages
I want to do Dunnett's test in Python
[Linux command] less command option list [Must-see for beginners]
I want to have recursion come to my mind
I want to easily create a Noise Model
I want to use MATLAB feval with python
I want to pin Datetime.now in Django tests
I want to analyze songs with Spotify API 2