nntrn / save

https://nntrn.github.io/save/
2 stars 0 forks source link

Snippets #20

Open nntrn opened 1 year ago

nntrn commented 1 year ago

Prompt Statements Variables

Read more: How-to: Setup Prompt Statement variables

nntrn commented 1 year ago
$ base64 -d <<<"H4sIAAAAAAAAA9WUPWvDMBCGd/0Knxct6o3BlikpGTqHYlq6qIopAUNqQ0m2/Pjoq/qyE6fQpTdaz/PK0p1dFLOFjJ3Gz2pTdeOJMSTZKtrVrF62z+36AD2PePb4lXMGg3NSQQBE5NC+OjAgAEKUJVXIVEAjrTPO17yAqJ/PHv9/Ck/DcPwe/mgHuSiwVCiwuS584AOA77QZnzc9C10uBND0klMC7+n4KEUDHCMS+nG/qjY+kajj5lqIjWg3jJybExNzS7m42/XHCe/KXRVx15upE6PhIErZ/IixmsjZLlxQqifcZvhL7dXLjUhCp1REbqbVmJMryQbYFoz6c41CbrqhOhsi9WtvBSXJ0CzJkxSSTN2yFwX4EZROXZZ01fW+hWh8pXbhHuusmkiTX6KkBUD9O8d4MN3wOq35+i7OkrcJzai1C9fflmABBgAA" | gunzip
                       .,,uod8B8bou,,.
              ..,uod8BBBBBBBBBBBBBBBBRPFT?l!i:.
         ,=m8BBBBBBBBBBBBBBBRPFT?!||||||||||||||
         !...:!TVBBBRPFT||||||||||!!^^""'   ||||
         !.......:!?|||||!!^^""'            ||||
         !.........||||                     ||||
         !.........||||                     ||||
         !.........||||                     ||||
         !.........||||                     ||||
         !.........||||       @nntrn        ||||
         !.........||||                     ||||
         `.........||||                    ,||||
          .;.......||||               _.-!!|||||
   .,uodWBBBBb.....||||       _.-!!|||||||||!:'
!YBBBBBBBBBBBBBBb..!|||:..-!!|||||||!iof68BBBBBb....
!..YBBBBBBBBBBBBBBb!!||||||||!iof68BBBBBBRPFT?!::   `.
!....YBBBBBBBBBBBBBBbaaitf68BBBBBBRPFT?!:::::::::     `.
!......YBBBBBBBBBBBBBBBBBBBRPFT?!::::::;:!^"`;:::       `.
!........YBBBBBBBBBBRPFT?!::::::::::^''...::::::;         iBBbo.
`..........YBRPFT?!::::::::::::::::::::::::;iof68bo.      WBBBBbo.
  `..........:::::::::::::::::::::::;iof688888888888b.     `YBBBP^'
    `........::::::::::::::::;iof688888888888888888888b.     `
      `......:::::::::;iof688888888888888888888888888888b.
        `....:::;iof688888888888888888888888888888888899fT!
          `..::!8888888888888888888888888888888899fT|!^"'
            `' !!988888888888888888888888899fT|!^"'
                `!!8888888888888888899fT|!^"'
                  `!988888888899fT|!^"'
                    `!9899fT|!^"'
                      `!^"'
nntrn commented 1 year ago

Publish step

    - name: Publish
      run: |
        git config --global user.email "actions@github.com"
        git config --global user.name "Actions"
        git add actions-cheat-sheet.*
        git commit -m 'AsciiDoctor-PDF build from Actions'
        git push --force origin HEAD:${GITHUB_REF#refs/heads/}
nntrn commented 1 year ago
$ a=1
$ result=$[$a + 3]
$ echo $result
4

https://linuxreviews.org/Bourne_Shell_Reference

nntrn commented 6 months ago

Also, don't forget to set PS4 to something useful like the following. In most cases set -x is useless without it.

export PS4='${BASH_SOURCE[0]}:$LINENO '

This will cause the script name and line numbers to be printed as well.

nntrn commented 3 months ago

find

Traversing the filesystem just once - for 2 different actions

find / \
    \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \
    \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
nntrn commented 3 months ago

Security

Terminate SSH Agent on Logout

# ~/.bash_profile
trap 'test -n "$SSH_AGENT_PID" && eval `/usr/bin/ssh-agent -k`' 0
nntrn commented 1 month ago

encrypt files with gpg

echo 'helloooooo' >password.txt
SECRET_PASSPHRASE=hello

# encrypt file (creates password.txt.gpg)
gpg --symmetric --cipher-algo AES256 password.txt

# decrypt
gpg --quiet --batch --yes --decrypt --passphrase="$SECRET_PASSPHRASE" --output /tmp/password.txt password.txt.gpg

https://docs.github.com/en/actions/security-guides/encrypted-secrets

nntrn commented 1 month ago

Count words using tr

tr '[:upper:]' '[:lower:]' < whats.gnu | 
  tr -cd '[:alnum:]_ \n' | 
  tr -s ' ' '\n' | 
  sort | 
  uniq -c