Paolo Redaelli personal blog

Category: Tricks

Never* use git pull – YouTube

    Just a quick summary mostly for myself:

    How to use git pull --rebase to keep your team’s commit history clean.

    Command for creating the ‘git pr‘ alias (so you can copy-paste): git config --global alias.pr "pull --rebase"

    1. Always try git pull --rebase first. It if works, you’re done!
    2. If you get a merge conflix, you can undo everything with git rebase --abort
    3. Then just pull “normally” using git pull, or do an interactive rebase (advanced)

    40 tools for ethical hacking

    I know many of them, but not everyone! Shame on me! Here are 40 tools for ethical hacking! Nmap: Network scanner used for network discovery and security auditing. Wireshark: Network protocol analyzer for packet inspection and troubleshooting. Metasploit: Penetration testing framework for exploiting vulnerabilities. John the Ripper: Password cracking tool for dictionary and brute-force attacks.…

    The different extended pattern matching operators are listed below, where pattern-list is a list containing one or more filenames, separated using the | character:

    1. *(pattern-list) – matches zero or more occurrences of the specified patterns
    2. ?(pattern-list) – matches zero or one occurrence of the specified patterns
    3. +(pattern-list) – matches one or more occurrences of the specified patterns
    4. @(pattern-list) – matches one of the specified patterns
    5. !(pattern-list) – matches anything except one of the given patterns

    To use them, enable the extglob shell option as follows:

    # shopt -s extglob
    

    1. To delete all files in a directory except filename, type the command below:

    $ rm -v !("filename")
    
    Delete All Files Except One File in Linux

    2. To delete all files with the exception of filename1 and filename2:

    $ rm -v !("filename1"|"filename2") 
    
    Source: 3 Ways to Delete All Files in a Directory Except One or Few Files with Extensions

    In bash scripting, the replacement of string is important because it allows you to modify a variable and the text of a file. It also helps in file and text processing and to validate user input.

    To replace a string in bash, check the following methods:

    1. Using Parameter expansion: ${String/pattern/replacement}
    2. Using the sed command: sed 's/pattern/replacement/' filename
    3. Using the awk command: "input_str" | awk 'pattern { action }'
    4. Using the perl command: perl [options] -e 'action' filename
    5. Using the tr command: tr 'old_chars' 'new_chars' < "input_file"

    Dive into the article to learn these methods of how to replace a bash string in detail.

    Source: How to Replace String in Bash? [5 Methods] – LinuxSimply