How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

The Silver Searcher – A Code Searching Tool for Programmers

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
23
VIEWS
Share on FacebookShare on Twitter

Contents

  1. How to Install and Use The Silver Searcher in Linux

The Silver Searcher is a free and open source, cross platform source code searching tool similar to ack (a grep-like tool for programmers) but faster. It runs on Unix-like systems and Windows operating systems.

The major difference between the silver searcher and ack is that the former is designed for speed, and benchmark tests prove that it is indeed faster.

If you spend a lot of time reading and searching through your code, then you need this tool. It aims at being fast and ignoring files that you don’t want to be searched. In this guide, we will show how to install and use The Silver Searcher in Linux.

How to Install and Use The Silver Searcher in Linux

The silver searcher package is available on most Linux distributions, you can easily install it via your package manager as shown.

$ sudo apt install silversearcher-ag					#Debian/Ubuntu 
$ sudo yum install epel-release the_silver_searcher		        #RHEL/CentOS
$ sudo dnf install silversearcher-ag					#Fedora 22+
$ sudo zypper install the_silver_searcher				#openSUSE
$ sudo pacman -S the_silver_searcher           				#Arch 

After installing it, you can run the ag command line tool with the following syntax.

$ ag file-type options PATTERN /path/to/file

To see a list of all supported file types, use the following command.

$ ag  --list-file-types

This example shows how to recursively search for all scripts that contain the word “root” under the directory ~/bin/.

$ ag root ./bin/
The Silver Searcher – A Code Searching Tool for Programmers

Search a Pattern in Files

To print the filenames matching PATTERN and the number of matches in each file, other than the number of matching lines, use the -c switch as shown.

$ ag -c root ./bin/
The Silver Searcher – A Code Searching Tool for Programmers

Print Number of Matches

To match case-sensitively, add the -s flag as shown.

$ ag -cs ROOT ./bin/
$ ag -cs root ./bin/
The Silver Searcher – A Code Searching Tool for Programmers

Match Case Sensitive

To print statistics of of a search operation such as files scanned, time taken, etc., use the the --stats option.

$ ag -c root --stats ./bin/
The Silver Searcher – A Code Searching Tool for Programmers

Print Search Operations Summary

The -w flag tells ag to only match whole words similar to grep command.

$ ag -w root ./bin/

You can show column numbers in results using the --column option.

$ ag --column root ./bin/
The Silver Searcher – A Code Searching Tool for Programmers

Show Column Numbers in Output

You can also use ag to search through purely text files, using the -t switch and the -a switch is used to search all types of files. In addition, the -u switch enables searching though all files, including hidden files.

$ ag -t root /etc/
OR
$ ag -a root /etc/
OR
$ ag -u root /etc/

Ag also supports searching through the contents of compressed files, using the -z flag.

$ ag -z root wondershaper.gz
The Silver Searcher – A Code Searching Tool for Programmers

Search Content in Compressed Files

You can also enable following of symbolic links (symlinks in short) with the -f flag.

$ ag -tf root /etc/ 

By default, ag searches 25 directories deep, you can set the depth of the search using the --depth switch, for example.

$ ag --depth 40 -tf root /etc/

For more information, see the silver searcher’s man page for a complete list of usage options.

$ man ag

To find out, how the silver searcher works, see its Github repository: https://github.com/ggreer/the_silver_searcher.

That’s it! The Silver Searcher is a fast, useful tool for searching through files that make sense to search. It is intended for programmers for quickly searching though large source-code base. You can give it a try and share your thoughts, with us via the comment form below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install Apache Tomcat 8 on CentOS 7
Linux

How to Install Apache Tomcat 8 on CentOS 7?

February 11, 2020
Install Arch Linux With Btrfs Snapshotting
Uncategorized

Install Arch Linux With Btrfs Snapshotting

February 13, 2020
Next Post

How Do I Access or Mount Windows/USB NTFS Partition in RHEL/CentOS/Fedora

How to Enable Syntax Highlighting in Vi/Vim Editor

Securing SSH Using Key Based Authentication

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

Installing Fuel CMS on FreeBSD 12.0

3 years ago

Setup Subversion (SVN) Repositories on Debian/Ubuntu

3 years ago

Setting up Ghost Professional Publishing Platform on OpenBSD 6

3 years ago

10 Practical Examples Using Wildcards to Match Filenames in Linux

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.