Execute previous command with a string replacement (only works on first string)
$ ls *.tmp
$ ^ls^rm
rm *.tmp
$ cp -i file1 file2 file3 destdir
$ ^-i # no 2nd string replaces with nothing
cp file1 file2 file3 destdir
Replace all occurrences of string in previous command:
$ echo 4 4 4 4 4
$ !:gs/4/5/
echo 5 5 5 5 5
Access previous commands:
$ls -l *.txt
$ !! # run the last command
ls -l *.txt
$ !-1 # same as !!
$ !-2 # run the command before the last one
$ !-3 # run the 3rd previous command
Access the parameters of the previous command:
$ cp file1 file2 file3 destdir
$ echo !$
destdir
$ echo !*
file1 file2 file3 destdir
Creates 1GB files full of zeros. Wipes almost all of the free space. Use a for loop to create the files on each filesystem. Run until the filesystem fills up before deleting zero files.
for (( i=1; i<=10; i++ ))
do
num=$(printf "%03d" $i)
echo $num
dd bs=1024 count=1024K if=/dev/zero of=zero-$num
sync
doneIn RedHat Enterprise, and maybe others:
badblocks -w -s -p # [device]Where # is the number of passes you want to use and device refers to the partition (/dev/sda1) or whole device (/dev/sda) you want to wipe.
For testing out a new mail server, etc...
HELO mydomain.com
MAIL FROM: <from@mydomain.com>
RCPT TO: <user@server.com>
DATA
Subject: testing 123
To: <user@server.com>
This is a test message
.
QUIT
#!/usr/bin/perl
# rexname - Larry's filename fixer
#
# Modified by Brian Mathis to add testing and verbose
#
use strict;
use Getopt::Long;
my $usage = <
rexname expr [files]
rexname --test expr [files]
rexname --verbose expr [files]
Options:
--test (-t)
Don't actually do anything (implies -v)
--verbose (-v)
Display output of changes as they are made
USAGE
my($test, $verbose);
GetOptions("test" => \$test, "verbose" => \$verbose);
if($test) { $verbose = 1; }
my $op = shift or die $usage;
chomp(@ARGV =
for (@ARGV) {
my $was = $_;
eval $op;
die $@ if $@;
print "$was \t-> $_\n" if $verbose;
Used with cygwin. Helpful when using rxvt as the cygwin terminal.
xterm*foreground: gray
xterm*background: black
xterm*geometry: 132x50
xterm*saveLines: 1000
xterm*scrollBar: true
xterm*rightScrollBar: true
xterm*loginShell: true
rxvt*foreground: gray
rxvt*background: black
rxvt*geometry: 132x50
rxvt*saveLines: 1000
rxvt*scrollBar: true
rxvt*scrollBar_right: true
rxvt*loginShell: true
rxvt*font: DejaVu Sans Mono-13
# Change scrollback to 10000 lines
defscrollback 10000
# status line at the bottom
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%f%n %t%{-}%+w %=%{..G}[%H %l] %{..Y} %m/%d %c "
# allow scrollback to work in terminal programs (like putty)
termcapinfo xterm ti@:te@