Formatting strings
printf "%s %d %d %d\n" "Testing" 1 2 3
Output:
Testing 1 2 3
Remove whitespace
#!/usr/bin/env python3 | |
""" Checks if a password has been pwned using the haveibeenpwned.com API. | |
""" | |
import getpass | |
import hashlib | |
import requests | |
def get_matching_list(hash_prefix): |
# myfile.csv is a CSV export of a Google sheet. that contains name, email, and affiliation . | |
# The first three lines are headings and boilerplate. "-n +4" tells tail to only display line 4 and later. | |
# The cut command extracts the second column (email addresses) using ',' as the delimiter. | |
# tr transforms the newlines into commas to create a comma-separated list of only email addresses. | |
tail -n +4 myfile.csv | cut -d ',' -f 2 | tr '\n' ',' |
# ls -s displays the size of files, in blocks, followed by the file name. | |
# For convenience, I am setting the block size to 1024 bytes, or 1 kilobyte. | |
# The output of ls -s is piped to an awk command that incrementally adds the file sizes and displays the total. | |
ls --block-size=1024 -s /path/to/files | awk '{ total += $1 }; END { print total }' |
Formatting strings
printf "%s %d %d %d\n" "Testing" 1 2 3
Output:
Testing 1 2 3
Remove whitespace
Google search results used to include a link to a cached version, but alas, that is no more. What should you do if a page has disappeared or changed? Try this URL to search the Google cache:
http://webcache.googleusercontent.com/search?q=cache:http://example.com/
Replace example.com with the actual URL you want.
# Deletes empty (size 0) files from the directory provided as a command-line | |
# argument. Currently does not descend into subdirectories. | |
# Created August 2005. | |
# author: Shang-Lin Chen | |
use File::stat; | |
use File::Copy "move"; | |
$num_args = @ARGV; |
#!/bin/bash | |
# clear_ipc | |
# | |
# Delete the IPC objects created by a user. The user and IPC type are specified on the command | |
# line. | |
# | |
# usage: clear_ipc username type | |
USERNAME=$1 |
# Demo of how to process files in Perl. | |
# Replace with the actual name of the file. | |
my $file_name = "myfile.txt"; | |
# Open the input file read-only. | |
open(IN, "<$file_name") or die "Cannot open $file_name\n"; | |
# Open the output file for writing. | |
open(OUT, ">outputfile.txt") or die "Cannot open output file\n"; |