View Single Post
  #4 (permalink)  
Old 03-12-2009, 05:06 PM
sweta's Avatar
sweta sweta is offline
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
OS: Suse, RHEL, Vista
Posts: 199
Thanks: 12
Thanked 9 Times in 9 Posts
Rep Power: 7
sweta has a spectacular aura about sweta has a spectacular aura about
Default

Getting dir name or only a file name from a long path is also pretty handy when you use rsync or scp / ssh and friends

Code:
rsync /nas/a/x/y/foo/bar.txt root@server1:/dest/to/path
No I want only dir name
Code:
rsync -a !!:1:h !!:2
Get filename but leaving the dir:
Code:
cp /path/to/logn/dir/foofilenameverylongfilename.txt /mnt/floppy
oh no foofilenameverylongfilename.txt is in current dir:
Code:
cp !!:1:t !!:2
and the best one find and replace arg:
Code:
scp user@server1:/path/to/alongdir1/file.txt user@server2:/dest
on no dir1 must be dir2:
Code:
scp !!:1:s/dir1/dir2 !!:2

FYI, they are called history modifiers.
__________________
Reply With Quote
The Following User Says Thank You to sweta For This Useful Post:
kumarat9pm (04-12-2009)