Check These Out
Pure Bash
This will print a row of characters the width of the screen without using any external executables. In some cases, COLUMNS may not be set. Here is an alternative that uses tput to generate a default if that's the case. And it still avoids using tr.
$ printf -v row "%${COLUMNS:-$(tput cols)}s"; echo ${row// /#}
The only disadvantage to either one is that they create a variable.
Starting with a large MySQL dump file (*.sql) remove any lines that have inserts for the specified table. Sometimes one or two tables are very large and uneeded, eg. log tables. To exclude multiple tables you can get fancy with sed, or just run the command again on subsequently generated files.
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
This command prints the Date (Not time) from 3 days ago (72 hours ago).
This works on systems without GNU date (MacOSX , Solaris, FreeBSD).
You can use the -format switch to get the size of the image. Replace "logo:" with your image.
Here we instead show a more real figure for how much free RAM you have when taking into consideration buffers that can be freed if needed.
Unix machines leave data in memory but marked it free to overwrite, so using the first line from the "free" command will mostly give you back a reading showing you are almost out of memory, but in fact you are not, as the system can free up memory as soon as it is needed.
I just noticed the free command is not on my OpenBSD box.
Overwrites the boot sector. Since this doesn't overwrite any data, you can usually recover by re-creating the partition table exactly the same as before you zeroed it. This can also help sometimes if you install a new drive in a Windows machine which can't read it.
Very useful set of commands to know when your file system was created.