NetAdminTools.com
 
Categories:
GNU/Linux | Homebrew designs | Perl | Ruby | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | ERP | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Ruby
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·ERP
·REALbasic
·All Categories


Stupid Bash Tricks: Repeat Last Argument to Last Command
Topic:GNU/Linux   Date: 2002-06-24
Printer Friendly: Print   Mobile View: mobile

spacerspacer
<<  <   >  >>

Subject

Did you know that you can recall the last argument to the last command you typed by using the special variable !$. This can be handy when you are working with host names, long file names, all sorts of things. A few examples:

See if a host is up and log in:

usr-3@srv-3 usr-3]$ ping e2500.prod.bigfatdomain.com
(output of ping snipped -- you've seen it before!)
[usr-3@srv-3 usr-3]$ ssh !$
ssh e2500.prod.bigfatdomain.com
[email protected]'s password:
User Names:

[root@srv-3 usr-3]# useradd -u 666 -g 100 udergahad
[root@srv-3 usr-3]# passwd !$
passwd udergahad
Changing password for user udergahad.
New UNIX password:
File Operations:

[root@srv-3 usr-3]# ls -l /var/log/messages
-rw-------    1 root    root     5490 Jun 24 09:20 /var/log/messages
[root@srv-3 usr-3]# cp !$ !$.020624
cp /var/log/messages /var/log/messages.020624
[root@srv-3 usr-3]# scp !$ atom:/share/usr-3/
scp /var/log/messages.020624 atom:/share/usr-3/
root@atom's password:
messages.020624   100% |*********************|  5490     00:00
[root@srv-3 usr-3]#
Those are just some dumb examples, but you'll get a lot of bang from your buck with this trick.
People:
Places:
Things:
Times:





Please read our Terms of Use and our Privacy Policy
Microsoft, Windows, Windows Server are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2013 NetAdminTools.com