An open API service indexing awesome lists of open source software.

https://github.com/tomasfn87/bci

Download Linux CLI tool here! - Search Script for Bash
https://github.com/tomasfn87/bci

grep linux-cli linux-shell search

Last synced: 11 months ago
JSON representation

Download Linux CLI tool here! - Search Script for Bash

Awesome Lists containing this project

README

          

# `bci` / `gbci`


## *Search Script for* `GNU/Linux`


- `bci` and `gbci` use `egrep` and `grep` to show a list a of files that contain a piece of text, showing the user a pretty colored output;
- the first element of each line of a sucessfull search is the number of ocurrences, and the second is the filepath where the specified text was found;
- if the specified directory doesn't exists, a corresponding **Error** message will be thrown.

---


- Get this CLI tool for your `Linux` distro by using the `install` command below;
- Two new commands will be at your disposal:
- `bci`;
- `gbci`.
- They work the same way, but `bci` output is __red__;
- In case you prefer a more *__Old School__* style, `gbci` stands for *__green__* `bci`; it's also useful when further refining the search with `grep`, whose highlighting is already red.

---



## Commands

### *Install*:

```shell
sudo git clone --depth 1 --no-checkout https://github.com/tomasfn87/bci /usr/local/lib/bci && pushd /usr/local/lib/bci && sudo git sparse-checkout set {g,}bci.sh && sudo git checkout && sudo ln -rs /usr/local/lib/bci/bci.sh /usr/local/bin/bci && sudo ln -rs /usr/local/lib/bci/gbci.sh /usr/local/bin/gbci && popd && echo "\nUse commands bci and gbci to search through the files' content in a directory."
```

### *Uninstall*:

```shell
sudo rm -rf /usr/local/{lib/bci,bin/{g,}bci}
```

### *Update*:

```shell
sudo rm -rf /usr/local/lib/bci && sudo git clone --depth 1 --no-checkout https://github.com/tomasfn87/bci /usr/local/lib/bci && pushd /usr/local/lib/bci && sudo git sparse-checkout set {g,}bci.sh && sudo git checkout && popd && echo "\nbci and gbci were updated to the latest version."
```

---



## Arguments

- `SEARCH_TERM`: _the 1st argument is the_ SEARCH TERM _that will be searched inside all the files available_;
- `SEARCH_DIRECTORY`: _the 2nd argument is the_ SEARCH DIRECTORY _where the search will take place_.

---



## _Examples_:

*Basic operations*:


```shell
bci 'import datetime as dt' ~/python
```

*Search for* `import datetime as dt` *into folder* `~/python`


```shell
gbci export\ default /home/user/mySite
```

*Search for* `export default` *into folder* `/home/user/mySite`

---



*Further refining the search*:


```shell
gbci export\ default /home/user/mySite | grep \\.ts

# or

gbci "export default" /home/user/mySite | grep \\.\[jt\]s
```

- *Refine the search further by piping* `grep`;
- *Works better with* `gbci` *because* `grep` *uses* **red** *to mark the returned results*.