Check These Out
when using Gnome or KDE, you will have a hard time getting a screenshot of something like a login screen, or any other screen that occurs before the desktop environment is up and monitoring the printscreen key. (this probably applies for other DEs as well, but I haven't used them)
What this command is meant to do is take a screenshot of an X window using a command you can run from your virtual terminals (actual text terminals, not just an emulator) To do this:
Press CTRL+ALT+F1 to go to a virtual (text) terminal once your login window comes up
Login to the virtual terminal and enter the command (you'll have to type it in)
You should now have a file called screenshot.png in your home directory with your screenshot in it.
For those of you who are new to the virtual terminal thing, you can use CTRL+ALT+F7 to get back to your regular GUI
From http://www.gnome.org
The command cechks if we are connected to a X11 console, if the $TERM var noct yet contains a "screen" derivat, and only then attachs to tmux.
You could add a test for interactive shell [[ $- == *i* ]] but your .bashrc has that already, I bet.
"What it actually shows is going to be dependent on the commands you've previously entered.
When you do this, bash looks for the last command that you entered that contains the substring "ls", in my case that was "lsof ...". If the command that bash finds is what you're looking for, just hit Enter to execute it. You can also edit the command to suit your current needs before executing it (use the left and right arrow keys to move through it).
If you're looking for a different command, hit Ctrl+R again to find a matching command further back in the command history. You can also continue to type a longer substring to refine the search, since searching is incremental.
Note that the substring you enter is searched for throughout the command, not just at the beginning of the command." - http://www.linuxjournal.com/content/using-bash-history-more-efficiently
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"
}
In this example, file contains five columns where first column is text. Variance is calculated for columns 2 - 5 by using perl module Statistics::Descriptive. There are many more statistical functions available in the module.
./* is for copying files starting with -
.[!.]* is for copying hidden files and avoiding copying files from the parent directory.
..?* is for copying files starting with .. (avoids the directory ..)
/path/to/dir the path to the directory where the files should be copied
Can also be used as a script. Input argument is /path/to/dir
in tcsh, replace .[!.]* with .[^.]*
Alternatively:
export MyVAR=84; awk '{ print ENVIRON["MyVAR"] }'
I recently found myself with a filesystem I couldn't write to and a bunch of files I had to get the hell out of dodge, preferably not one at a time. This command makes it possible to pack a bunch of files into a single archive and write it to a remote server.