JustToThePoint English Website Version
JustToThePoint en español
JustToThePoint in Thai

Command linux tools: find (exec), bat, fzf, exa, ripgrep, youtube-dl, xclip

Exa/lsd

exa is a modern replacement for ls: brew install exa (macOS), sudo pacman -Sy –noconfirmm exa (Arch), apt install exa (Ubuntu). Awesome command linux tools

Bat

Bat is a cat clone with wings, it supports syntax highlighting and Git integration.

  1. Installation: choco install bat (Windows), sudo apt install bat (Ubuntu), pacman -S bat (Arch).
  2. If you install bat this way, the executable may be installed as batcat instead of bat. You can set up a bat–> batcat symlink: ln -s /usr/bin/batcat ~/.local/bin/bat.
    Replace cat with bat, nvim .zsh_aliases: alias cat=‘bat ‐‐style=plain’

ripgrep

ripgrep is a line-oriented search tool that recursively searches the current directory for a regex pattern.

Installation: brew install ripgrep (macOS), choco install ripgrep (Windows), pacman -S ripgrep (Arch), sudo apt-get install ripgrep (Debian, Ubuntu).

How do I find all files containing a specific text? Using grep: grep -rnw “/path/to/somewhere” -e “specificText” (-r: recursive; -n: line number; w: match the whole world). Using ripgrep: ripgrep “specificText/pattern” /path/

Youtube-dl

youtube-dl download videos from YouTube.com or other video platforms.

Find is more than it looks (exec option)

# Recursively delete files with a particular extension using the find command
find . -type f -name "*.ext" -exec rm -v {} \;

There are two parts:

  1. find . -type f -name “.ext” . Search for regular files (-type -f, i.e., it excludes directories, symbolic links, etc.) with the .ext extension (-name “.ext”, e.g., txt, jpg, md, etc.) in the current directory (.)

  2. -exec rm -v {} ; . This is the second part, it executes rm, i.e., remove each file found by the previous order (find). The {} is a placeholder for the found filenames. The ; indicates the end of the -exec command.

Fzf

fzf is a general-purpose command-line fuzzy finder.

  1. Installation: Windows (choco install fzf)

      brew install fzf # macOS
      $(brew --prefix)/opt/fzf/install # To install useful key bindings and fuzzy completion
    
      git clone ‐‐depth 1 https://github.com/junegunn/fzf.git ~/.fzf # GNU/Linux
      ~/.fzf/install 
    

    Do you want to enable fuzzy auto-completion? ([y]/n) y
    Do you want to enable key bindings? ([y]/n) y
    Do you want to update your shell configuration files? ([y]/n) y
    It will add this line (vim .bashrc): [ -f ~/.fzf.bash ] && source ~/.fzf.bash

  2. Let’s find files ending with .md: fzf ‐‐query=.md$

  3. Fuzzy search can be triggered with **: cd **<TAB>, cd ~/.config/cal**<TAB> (it searches for files and directories under ~/.config that match `cal`: /home/myUser/.config/calcurse), vim .config/default.yml** (my first result is .config/espanso/default.yml). Fuzzy completion for PIDs is provided for the kill command: kill -9 . You may also want to preview the files: fzf ‐‐preview ‘cat {}’

  4. You could use bat for this purpose. Use: fzf ‐‐preview ‘bat ‐‐color=always ‐‐style=numbers ‐‐line-range=:500 {}’

    nvim .bash_aliases/.zsh_aliases: #Credits: Luke Smith.

    alias prev="fzf ‐‐preview 'bat ‐‐style=numbers ‐‐color=always {}'"
    searchEdit() { du -a ~/Dropbox/ ~/.config/ | awk '{print $2}' | fzf | xargs -r $EDITOR ; }
    

Xclip or pbcopy

Copy and paste at the command line with xclip (GNU/Linux) or pbcopy (macOS):

It is a command-line clipboard manager. It enables you to copy the standard input from your terminal to your clipboard, so you can paste it to a GUI application (gedit, atom, brave, etc.)

Use. Copy a file into the clipboard: cat file | xclip -sel clip. Let’s copy a password to the clipboard: pass Root/Ocio/amazon.es | xclip -sel clip. To paste the text you just copied, you should use: xclip -selection clipboard -o

Bitcoin donation

JustToThePoint Copyright © 2011 - 2024 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.