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]/../
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]/../
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
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/../