Reputation: 21858
In my previous question I created a command that reverts svn files by pattern:
svn st | grep SomeFolderA | awk {'print $2'} | xargs svn revert
Now I want to make it a command that accepts argument (file pattern) and runs the above command by using the argument instead of SomeFolderA
. I tried adding this to my .bash_profile
file:
function revert() {
"svn st | grep '$1' | awk '{print \$2}' | xargs svn revert" ;
}
When I run revert SomeFolderA
I get this output:
-bash: svn st | grep 'SomeFolderA/' | awk '{print $2}' | xargs svn revert: No such file or directory
I also tried using the complete path for the svn
but it still doesn't work. What am I missing?
Upvotes: 0
Views: 292
Reputation: 12672
Create a variable with your command string and execute it
function revert() {
cmd="svn st | grep '$1' | awk '{print \$2}' | xargs svn revert"
eval $cmd
}
Upvotes: 1
Reputation: 1283
No need to use function, put off the function, just use below in you script :
svn st | grep "$1" | awk '{print \$2}' | xargs svn revert
Upvotes: 0