Hacker News new | ask | show | jobs
by throwaway823882 1874 days ago
Less-common one-liners that I use for work:

  # Use jq to craft json documents
  jq -en --rawfile key some_id_rsa \
    '{ "ssh_private_key": $key, "hosts": [ 
         { "type": "EC2", "name": "backenddev", "id": "i-0123456789", "address": "1.2.3.4", "region": "us-west-1" } 
     ] }' > metadata.json
  
  # Use jq to import Terraform resources from a state file
  jq -er '.modules[].resources | to_entries | .[] | [ "terraform", "import", .key, .value.primary.id ] | @sh' \
    generated/aws/route53/terraform.tfstate \
  | xargs -L1 env
  
  # Use Bash to check for a TCP connection (like 'nc -z')
  timeout 1 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/3306'