less command in linux with examples | Pro Tech guides

less command in linux with examples

less command in linux allows you to display the content of the file, search a word. Navigate to pages and lines.

less command in linux | It's features | with examples

linux command less
less command in linux

Hello, guys welcome to the next session on Linux command line tutorial. In this session, we will see how we can use "less command" in Linux.

"less command" is used to read the files or if you want to search something inside the file something like patterns or some word.

Then you can use "less" command conveniently to read or search in the file.

So let's see how we can use it.

First of all, I will navigate to my desktop where the "bigfile.txt" file is there.

For example, I want to see the content of this "bigfile.txt" text file. You can also use the "cat" command to read a file. But there is a drawback.

That's why we can use "less command" to overcome these problems. And also "less" has its own features.

less command

less command in linux to read a file
less command to read a file

$less fileName

Now I'm going to use "less" for reading the file content. So first of all for using less you just need to write less and the name of the file which is "bigfile.txt" and press ENTER.


less command example
less command example

And you can see it will show you the content of the file from the starting. So this is the starting of the file and it'll show you some text until this terminal allows to show.


To go one line Down

down arrow
If you go on to see the content of the file more. You can hit the "down arrow" key.

So down arrow key allows you to go one line down at a time.

To go one line up

up arrow
And if you hit "up arrow" then you can read up or you can browse over the file in the up.

Go to Next page

space bar key
If you want to go through the file, page by page, You can use a "space key" to navigate to your file, page by page.

So when I press a "space" it's going to show me the next page.

Go to the previous page

b
Now if you want to go the previous page by page. You can just press "b" and you will go one page up at a time.

Go to end of file

Shift + G
If you want to go to the end of the file. You can just press "Shift + G" and browse to the end of your text file.

Go to the beginning of the file

lg
If you want to go to the top at the starting of your file. You can just type "1g"

It will go at the beginning of the file.

Search Forward

/searchTerm
I want to search something inside this text file from "up to down".

So I can use this forward-slash (/). Which says this "less" that I want to search from up to down.

to find a word in linux using less command
To find a word using less command

For example, You are looking for the word "cat" inside this text file just type "/catpress ENTER.

It's going to show you or highlight the first "cat" keyword. Which you are searching for.

Jump to next iteration

n
Now to search or to go to the next "cat" in the text file. You can press "n" to go to the next item.

Search Backward

?searchTerm
Sometimes you may want to search from down to up.

And for this, you can use this question mark (?) for searching from down to up and then you can give your keyword.

which you are looking for and press ENTER.

Quit less command

Q
Now if you want to "quit" less command. You just need to press "Q" it'll quit your less command.

Conclusion

So this is how you can use "less command" in Linux.

And if you want to know more about less you can just write "man less".

This will show you the description of less command and the flags and the keys. You can use it with less command.

I hope you enjoyed this tutorial kindly rate comment and bye for now.

HAVE A NICE DAY 💖

Name

Apps,3,Games,1,Linux,38,Linux Commands,37,Network-Devices,1,Networking,1,Terminal Apps,2,Termux,17,Userland,3,Windows,1,
ltr
item
Pro Tech guides: less command in linux with examples
less command in linux with examples
less command in linux allows you to display the content of the file, search a word. Navigate to pages and lines.
https://1.bp.blogspot.com/-9I8n_kRfj7Y/X8jr70qhbDI/AAAAAAAAChA/1rTtqHopXp8JecnX880n2pY9onQMuh99QCNcBGAsYHQ/s16000/less%2Bcommand.png
https://1.bp.blogspot.com/-9I8n_kRfj7Y/X8jr70qhbDI/AAAAAAAAChA/1rTtqHopXp8JecnX880n2pY9onQMuh99QCNcBGAsYHQ/s72-c/less%2Bcommand.png
Pro Tech guides
http://www.protechguidez.com/2020/12/less-command-in-linux-with-examples.html
http://www.protechguidez.com/
http://www.protechguidez.com/
http://www.protechguidez.com/2020/12/less-command-in-linux-with-examples.html
true
7053638852026728047
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content