Reputation: 15314
In bash, I want to search a directory which contains a file that I'm expecting:
find . -name "myfile-*.war"
assign the name of this file to a variable, and then rename the file to newfile.war.
Upvotes: 1
Views: 3806
Reputation: 780673
You don't need to assign the file to a variable, just rename it with the -execdir
option to find
:
find . -name 'myfile-*.var' -execdir mv {} newfile.war \;
Upvotes: 1
Reputation: 11084
If you are sure the find command will return exactly 1 file you can use this:
name=$(find . -name "myfile-*.war" )
Upvotes: 3