Question

In tcsh I'm trying to make an alias like

alias getit "mv /somedir/$* ."

If I then do

 getit foo.txt

tcsh tries to execute

mv /somedir/ foo.txt

i.e. it inserts an unwanted whitespace and tries to move /somedir/ into a non-existent directory foo.txt and rightly complains that it does not exit. What's the right way to write this command and suppress the whitespace?

Was it helpful?

Solution

Try this:

alias getit "mv /somedir/\!:1 ."

This will take the first argument passed to the alias and place it in the location of \!:1. If you want the glob form (all arguments) then you would use \!*, although I don't think that's what you want in this situation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top