NetWiki

I can make net work

User Tools

Site Tools


linux:bash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:bash [2023-09-25 20:36] – [Sort These] davelinux:bash [2023-09-25 20:44] (current) – [Bash] dave
Line 1: Line 1:
 ====== Bash ====== ====== Bash ======
-FIXME: This isn't really bash, it's random Linux stuff that I'm tired of looking up. +Bash stuff that I'm tired of looking for.
- +
-===== HowTo ===== +
-Find the subnet given IP and mask or CIDR +
-<code>ipcalc -n 172.16.16.113 255.255.255.252 | grep Network | awk '{print $2}' +
-172.16.16.112/30</code> +
-This assumes you have [[https://jodies.de/ipcalc|ipcalc]] installed (Github and download links at bottom of that page.)  FIXME: This shouldn't be under Linux. +
- +
-Pad an IP to make it sortable +
-<code>echo 172.16.16.112/30 | awk -F '[./]' '{printf "%03d.%03d.%03d.%03d/%03d\n", $1,$2,$3,$4,$5}' +
-172.016.016.112/030</code>+
  
  
Line 35: Line 25:
 ===== Detect if Script is Run by Cron ===== ===== Detect if Script is Run by Cron =====
 # Check if script is cron or shell - two versions. # Check if script is cron or shell - two versions.
 +  * [[https://stackoverflow.com/questions/3214935/can-a-bash-script-tell-if-its-being-run-via-cron|StackOverflow: Can a bash script tell if it's being run via cron?]]
 <code> <code>
-https://stackoverflow.com/questions/3214935/can-a-bash-script-tell-if-its-being-run-via-cron 
 if [ -t 1 ] ; then if [ -t 1 ] ; then
     echo "interacive mode";     echo "interacive mode";
Line 42: Line 32:
     #send mail     #send mail
 fi fi
 +</code>
  
------------------------+<code>
 CRON=$(pstree -s $$ | grep -q cron && echo true || echo false) CRON=$(pstree -s $$ | grep -q cron && echo true || echo false)
 then test with then test with
linux/bash.1695674205.txt.gz · Last modified: by dave

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki