Reputation: 79
I want to do this
mv <some path> <some path>/../
Is there a way to pass argv[1]
as my argument and manipulate it, instead of writing the whole path again?
I.e.,
mv <some path> argv[1]/../
Upvotes: 1
Views: 83
Reputation: 420971
In these situations, I usually use brace expansion:
mv <some path>{,/../}
which will expand to
mv <some path> <some path>/../
Example:
$ echo mv some/path{,/../other/path}
mv some/path some/path/../other/path
As @Pavlo Myroniuk points out in his answer, you can also follow the advice from here and do:
mv <some path> !#:1/../
Upvotes: 2
Reputation: 334
I've found the answer here. You can do it with:
mv file.txt !#:1.backup
!#
- refers to the current command.!#:1
- refers to the first argument of the current commandIf you run this example you'll get:
mv file.txt file.txt.backup
Upvotes: 5