Tuesday, 10 September 2013

Command line for copying a file named for its parent directory

Command line for copying a file named for its parent directory

I am having a brain cramp here. I'd like to be able to do something like
this ...
$ pwd
/user/red/thing1
$ cp ../file.txt basename `pwd`.txt
... and have the resulting file be named thing1.txt. When I run the above
command line I get this error, cp: target ``/users/red/thing1/thing1.txt'
is not a directory, which seems odd to me.
Thanks!

No comments:

Post a Comment