I do this in BASH

echo test "$1"

..expecting to get..

test test

..but I get..


Is this something possible to do? It would make my life easier since having a list files I could do something like mv a/b/test.py proj_copy/$1

  • 1
    echo test{,} ? – 123 Jun 24 '16 at 10:52

You can use history expansion

$ echo test !#:^
echo test test
test test

$ echo a/b/test.py proj_copy/!#:^
echo a/b/test.py proj_copy/a/b/test.py
a/b/test.py proj_copy/a/b/test.py

The entire command line typed so far.

The first argument

You could also use brace expansion

$echo test{,}
test test

$echo {,proj_copy}/a/b/test.py
/a/b/test.py proj_copy/a/b/test.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.