wiki.xw3.org

Welcome, this is not the xw3 project Wiki... But it is part of the xw3.org development infrastructure.

User Tools

Site Tools


useful_commands

Useful Commands

How to Exclude in Grep

To specify two or more search patterns, use the -e option:

grep -wv -e nologin -e bash /etc/passwd

Source: https://linuxize.com/post/grep-exclude/

Delete large directory fast (rm is too slow)

Start a webserver in current directory:

Use RangeHTTPServer Python module:

“python -m RangeHTTPServer” or “python3 -m http.server”

or use caddy:

caddy file-server –listen 0.0.0.0:8000

Get first field of a commands output:

awk -F ' ' '{print $1}'

Replace newlines with whitespaces in a file

Using sed

Using tr

A better option here is to use the tr command as follows:

tr '\n' ' ' < input_filename

or remove the newline characters entirely:

tr -d '\n' < input.txt > output.txt

or if you have the GNU version (with its long options)

tr --delete '\n' < input.txt > output.txt

Source: https://stackoverflow.com/questions/1251999/how-can-i-replace-each-newline-n-with-a-space-using-sed#1252010

Export and import private and public GPG keys

Export

gpg -a --export > mypubkeys.asc
gpg -a --export-secret-keys > myprivatekeys.asc
gpg --export-ownertrust > otrust.txt

Import

gpg --import myprivatekeys.asc
gpg --import mypubkeys.asc
gpg -K
gpg -k
gpg --import-ownertrust otrust.txt

Source: https://access.redhat.com/solutions/2115511

useful_commands.txt · Last modified: 2024-03-20 by hanez