Posted: . At: 8:28 AM. This was 1 year ago. Post ID: 17872
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

Install a lovely calculator to convert units.

There is a very nice calculator script that is able to convert any units of measurement to and fro to other units. This would be great to convert an old unit of measurement to a new unit.

Install this very easily.

[root@localhost Documents]# dnf in qalculate
Rocky Linux 9 - BaseOS                                                                                                                                                                                                                4.8 kB/s | 4.1 kB     00:00    
Rocky Linux 9 - AppStream                                                                                                                                                                                                             5.0 kB/s | 4.5 kB     00:00    
Rocky Linux 9 - CRB                                                                                                                                                                                                                   4.5 kB/s | 4.1 kB     00:00    
Rocky Linux 9 - Extras                                                                                                                                                                                                                3.6 kB/s | 2.9 kB     00:00    
Rocky Linux 9 - Extras                                                                                                                                                                                                                8.5 kB/s | 8.7 kB     00:01    
Dependencies resolved.
======================================================================================================================================================================================================================================================================
 Package                                                            Architecture                                                 Version                                                             Repository                                                  Size
======================================================================================================================================================================================================================================================================
Installing:
 qalculate                                                          x86_64                                                       3.22.0-1.el9                                                        epel                                                       210 k
Installing dependencies:
 libqalculate                                                       x86_64                                                       3.22.0-1.el9                                                        epel                                                       1.9 M
 
Transaction Summary
======================================================================================================================================================================================================================================================================
Install  2 Packages
 
Total download size: 2.1 M
Installed size: 7.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): qalculate-3.22.0-1.el9.x86_64.rpm                                                                                                                                                                                              779 kB/s | 210 kB     00:00    
(2/2): libqalculate-3.22.0-1.el9.x86_64.rpm

Then converting units is very easy.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ qalc 
> 100 tons to pounds
 
  100 × tonne ≈ 220462 lb + 4.194958041 oz
 
> 10 grams to grains
 
  10 × gram ≈ 154.3235835 gr
 
> 500 grains to grams
 
  500 × grain = 32.399455 g
 
>

Another example.

> 1000 yards to meters
 
  1000 × yard = 914.4 m

This is one very useful CLI tool for sure.

Access a CLI cheat sheet using the command line.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ curl cht.sh/ls
 cheat:ls 
# To display everything in <dir>, excluding hidden files:
ls <dir>
 
# To display everything in <dir>, including hidden files:
ls -a <dir>
 
# To display all files, along with the size (with unit suffixes) and timestamp:
ls -lh <dir>
 
# To display files, sorted by size:
ls -S <dir>
 
# To display directories only:
ls -d */ <dir>
 
# To display directories only, include hidden:
ls -d .*/ */ <dir>
 
# To display all files sorted by changed date, most recent first:
ls -ltc 
 
# To display files sorted by create time:
ls -lt
 
# To display files in a single column:
ls -1
 
# To show ACLs (MacOS):
# see also `cheat chmod` for `/bin/chmod` options for ACLs
/bin/ls -le
 
# To show all the subtree files (Recursive Mode):
ls -R
 
 tldr:ls 
# ls
# List directory contents.
# More information: <https://www.gnu.org/software/coreutils/ls>.
 
# List files one per line:
ls -1
 
# List all files, including hidden files:
ls -a
 
# List all files, with trailing `/` added to directory names:
ls -F
 
# Long format list (permissions, ownership, size, and modification date) of all files:
ls -la
 
# Long format list with size displayed using human-readable units (KiB, MiB, GiB):
ls -lh
 
# Long format list sorted by size (descending):
ls -lS
 
# Long format list of all files, sorted by modification date (oldest first):
ls -ltr
 
# Only list directories:
ls -d */

Use a version of the cat command with syntax highlighting.

[root@localhost bat]# dnf in bat
Last metadata expiration check: 0:23:51 ago on Wed 12 Apr 2023 07:21:25.
Dependencies resolved.
======================================================================================================================================================================================================================================================================
 Package                                                     Architecture                                                   Version                                                                Repository                                                    Size
======================================================================================================================================================================================================================================================================
Installing:
 bat                                                         x86_64                                                         0.21.0-7.el9                                                           epel                                                         2.2 M
 
Transaction Summary
======================================================================================================================================================================================================================================================================
Install  1 Package
 
Total download size: 2.2 M
Installed size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
bat-0.21.0-7.el9.x86_64.rpm

This is what it looks like.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ bat hello.s 
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       File: hello.s
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1    section .data
   2        msg db 'Hello, World!', 0xa ; string to be printed
   3        len equ $ - msg ; length of the string
   4    
   5    section .text
   6        global _start
   7    
   8    _start:
   9        ; write the message to the console
  10        mov eax, 4 ; set the system call number (sys_write)
  11        mov ebx, 1 ; set the file descriptor (stdout)
  12        mov ecx, msg ; set the message to write
  13        mov edx, len ; set the message length
  14        int 0x80 ; call the kernel
  15    
  16        ; exit the program
  17        mov eax, 1 ; set the system call number (sys_exit)
  18        xor ebx, ebx ; set the return code to 0
  19        int 0x80 ; call the kernel
  20    
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

This looks very good indeed, a good addition to any Linux machine.

Download the Rust source here: https://github.com/sharkdp/bat#installation.

A patch for cp and mv that lets you see the progress of the entire job rather than just single files. yeah, you could just use rsync but sometimes you really don’t need to use rsync but still want to see how long it will take.

https://github.com/jarun/advcpmv. This requires the source for cp and mv. But this would be a very useful patch.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.