If you find yourself needing to enter a very similar command multiple times this little command line trick that might save you some time. This is really only helpful if your command line is somewhat long and repetitive.
This is admittedly quite a contrived example but I think it gets the idea across:
example
123456789101112
scotmac:~ shewless$ ls file*.txt
file1.txt file2.txt
scotmac:~ shewless$ for i in `cat file1.txt`; do echo$i; donefoo
bar
apple
scotmac:~ shewless$ ^file1^file2
for i in `cat file2.txt`; do echo$i; donebaz
qux
banana
scotmac:~ shewless$
Step by step:
I have two files that I want to apply a similar action to:
list files
12
scotmac:~ shewless$ ls file*.txt
file1.txt file2.txt
I will run a command on file1.txt to list all of the lines in the file:
command on file1.txt
1234
scotmac:~ shewless$ for i in `cat file1.txt`; do echo$i; donefoo
bar
apple
I want to run the same command on file2.txt. Note the only input I have provided is the first line.
command on file2.txt
12345
scotmac:~ shewless$ ^file1^file2
for i in `cat file2.txt`; do echo$i; donebaz
qux
banana