Check These Out
see what's in your memory right now... sometimes you find passwords, account numbers and url's that were recently used. Anyone have a safe command to clear the memory without rebooting?
Efficiently clear all Windows Event log entries from within a Cygwin terminal. Uses "cygstart" to launch a hidden "PowerShell" session passing a Powershell command to loop through and clear all Windows Event Log entries. Very useful for troubleshooting and debugging. The command should in theory elevate you session if needed.
One liner is based on the PowerShell command:
$ wevtutil el | foreach { wevtutil cl $_ }
you could save the code between if and fi to a shell script named smiley.sh with the first argument as and then do a smiley.sh to see if the command succeeded. a bit needless but who cares ;)
This let's you find out the total packages that have available upgrades. Usefull if you want to check or show the total available upgrades on your system.
tar doesn't support wildcard for unpacking (so you can't use tar -xf *.tar) and it's shorter and simpler than
for i in *.tar;do tar -xf $i;done (or even 'for i in *.tar;tar -xf $i' in case of zsh)
-i says tar not to stop after first file (EOF)
This is useful if you'd like to see the output of a script while you edit it. Each time you save the file the command is executed. I thought for sure something like this already exists - and it probably does. I'm on an older system and tend to be missing some useful things.
Examples:
$ ontouchdo yourscript 'clear; yourscript somefiletoparse'
Edit yourscript in a separate window and see new results each time you save.
$ ontouchdo crufty.html 'clear; xmllint --noout crufty.html 2>&1 | head'
Keep editing krufty.html until the xmllint window is empty.
Note: Mac/bsd users should use stat -f%m. If you don't have stat, you can use perl -e '$f=shift; @s=stat($f); print "$s[9]\n";' $1
Don't copy trailing '=' or use head -c to limit to desired length.
This will perform one of two blocks of code, depending on the condition of the first. Essentially is a bash terniary operator.
To tell if a machine is up:
$ ping -c1 machine { echo succes;} || { echo failed; }
Because of the bash { } block operators, you can have multiple commands
$ ping -c1 machine && { echo success;log-timestamp.sh }|| { echo failed; email-admin.sh; }
Tips:
Remember, the { } operators are treated by bash as a reserved word: as such, they need a space on either side.
If you have a command that can fail at the end of the true block, consider ending said block with 'false' to prevent accidental execution