Compare commits
No commits in common. "137466a4235f87f14835da7cc3e7466af4aad29a" and "1ce84ebc53fc4e19bbd61d9ebcf2cdb10a225896" have entirely different histories.
137466a423
...
1ce84ebc53
17
Makefile
17
Makefile
@ -8,8 +8,6 @@ help: ## Print the help message
|
|||||||
|
|
||||||
articles != find * -type f -name "*.md"
|
articles != find * -type f -name "*.md"
|
||||||
|
|
||||||
categories != ls -d */
|
|
||||||
|
|
||||||
db.rec: $(articles)
|
db.rec: $(articles)
|
||||||
printf '%s\n' '%rec: guide' > $@
|
printf '%s\n' '%rec: guide' > $@
|
||||||
printf '%s\n' '%type: wordcount int' >> $@
|
printf '%s\n' '%type: wordcount int' >> $@
|
||||||
@ -43,14 +41,13 @@ database: $(default) ## Make a recfiles database
|
|||||||
|
|
||||||
.PHONY: article
|
.PHONY: article
|
||||||
article: ## Write an article
|
article: ## Write an article
|
||||||
@path=$$(find $(categories) -type d | sort | uniq | $(FZF)) ;\
|
@path=$$(find . -type d -printf '%P\n' | $(FZF)); \
|
||||||
read -p "Title: " title ;\
|
read -p "Title: " title; \
|
||||||
filename="$$(echo "$$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')" ;\
|
printf '%s\n' '---' >> $$path/$$title.md ; \
|
||||||
printf '%s\n' '---' >> $$path/$$filename.md ;\
|
printf 'title: "%s"\n' "$$title" >> $$path/$$title.md ; \
|
||||||
printf 'title: "%s"\n' "$$title" >> $$path/$$filename.md ;\
|
printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$title.md ; \
|
||||||
printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$filename.md ;\
|
printf '%s\n\n' '---' >> $$path/$$title.md ;\
|
||||||
printf '%s\n\n' '---' >> $$path/$$filename.md ;\
|
$(EDITOR) +5 $$path/$$title.md
|
||||||
$(EDITOR) +5 "$$path/$$filename.md"
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## Remove all generated files
|
clean: ## Remove all generated files
|
||||||
|
@ -6,28 +6,57 @@ tags: [ "Basics" ]
|
|||||||
|
|
||||||
`type` shows what kind of thing you're running, be it an alias, function, or binary program.
|
`type` shows what kind of thing you're running, be it an alias, function, or binary program.
|
||||||
|
|
||||||
```sh
|
```bash
|
||||||
type cd
|
type cmus
|
||||||
type ls
|
|
||||||
type -P ls
|
|
||||||
type -a cat
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Whereis the Program
|
# Whereis the Program
|
||||||
|
|
||||||
Where is `grep` and all its configuration files?
|
Ask where the `angband` program is, along with all its configuration files:
|
||||||
|
|
||||||
```sh
|
`whereis angband`
|
||||||
whereis grep
|
|
||||||
|
Also `which` shows where a binary file (the program) is,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
which cmus
|
||||||
```
|
```
|
||||||
|
|
||||||
Which one of these is the binary file which you actually use?
|
# Search Instantly with `plocate`
|
||||||
|
|
||||||
```sh
|
You can search every file on the computer instantly by installing `plocate`.
|
||||||
which grep
|
|
||||||
|
Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer.
|
||||||
|
|
||||||
|
Check how big the database is:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
du -h /var/lib/plocate/plocate.db
|
||||||
```
|
```
|
||||||
|
|
||||||
# More
|
Once you have the database, you can find nearly any file instantly.
|
||||||
|
|
||||||
- [Search instantly with `plocate`](data/search_system.md)
|
- Search for gifs: `locate .gif`
|
||||||
|
- Search for gifs in the `/usr/` directory: `locate /usr/ .gif`
|
||||||
|
- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg`
|
||||||
|
- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'`
|
||||||
|
|
||||||
|
For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md).
|
||||||
|
|
||||||
|
## Search More Places
|
||||||
|
|
||||||
|
`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go.
|
||||||
|
|
||||||
|
Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`.
|
||||||
|
|
||||||
|
By default, the `/mnt` directory is 'pruned' from the database.
|
||||||
|
So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file.
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat /etc/updatedb.conf
|
||||||
|
sudo sed 's#/mnt/##' /etc/updatedb.conf
|
||||||
|
sudo updatedb
|
||||||
|
plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Search System"
|
|
||||||
tags: [ "data", "search", "locate", "plocate" ]
|
|
||||||
requires: "cron"
|
|
||||||
---
|
|
||||||
|
|
||||||
You can search every file on the computer instantly by installing `plocate`.
|
|
||||||
|
|
||||||
Once installed, run `sudo updatedb` to create the database of (nearly) every file on the computer.
|
|
||||||
|
|
||||||
Check how big the database is:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
du -h /var/lib/plocate/plocate.db
|
|
||||||
```
|
|
||||||
|
|
||||||
Once you have the database, you can find nearly any file instantly.
|
|
||||||
|
|
||||||
- Search for gifs: `locate .gif`
|
|
||||||
- Search for gifs in the `/usr/` directory: `locate /usr/ .gif`
|
|
||||||
- Search for jpg images with 'dog' or 'Dog' in the name: `locate -i dog jpg`
|
|
||||||
- Search for videos: `plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'`
|
|
||||||
|
|
||||||
For best results, run `updatedb` regularly, perhaps in [crontab](../system/cron.md).
|
|
||||||
|
|
||||||
## Search More Places
|
|
||||||
|
|
||||||
`plocate` will not search `/tmp/`, because nobody cares about those files, and won't search inside `/mnt/`, because that's where USB sticks get mounted, so the files keep changing as USB sticks come and go.
|
|
||||||
|
|
||||||
Change where `plocate` searches by editing the configuration file at `/etc/updatedb.conf`.
|
|
||||||
|
|
||||||
By default, the `/mnt` directory is 'pruned' from the database.
|
|
||||||
So if you want to search `/mnt` for videos, remove the word `/mnt` from the configuration file.
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
su root
|
|
||||||
cat /etc/updatedb.conf
|
|
||||||
sed -i 's#/mnt/##' /etc/updatedb.conf
|
|
||||||
updatedb
|
|
||||||
exit
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you can search in `/mnt` for films:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
plocate --regex '.mp4$|.mkv$|.wmv$|.webm$|.mov$|.avi$'
|
|
||||||
```
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user