You are not logged in.
Here is a command I would like to make into an easy to use bash alias:
#Copy results of a find to somewhere
find -iname "*something*" -exec cp '{}' /path/to/copy/results/to \;I realize there are usually several ways to do something in the shell, so if a better way of course I'm all for any tips but if I wanted to make this an alias so that I just had to do:
alias pattern pathtocopytoHow would I? I have tried:
alias findcp="find -iname "$1" -exec cp '{}' $2/ \;"But this does not work, says it cannot find the search term when I ran it in a test dir full of properly named files and dirs.
TIA for any help ![]()
Last edited by colbert (2008-12-17 23:19:09)
Offline
Of course it does not
. Your definition breaks at the second double quote.
This is how it should be:
alias findcp="find -iname \"$1\" -exec cp '{}' $2/ \;"Then source your .bashrc (or log out and in again) and run alias to see if it's parsed correctly.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
That's not correct, before defining this alias $1 and $2 are expanded.
aliases can only put arguments at the back. For this construct you will need to use a function
function findcp() { find -iname "$1" -exec cp '{}' $2/ \; ;}Offline
Hmm, I tried that Procyon, I could see the HD light on the case go solid so it was running the find but it did not work. I have a file called "layla.mp3" and a dir called "test" in the current dir, ran it like this:
findcp layla testGave no result and test was still empty
Thanks for the help guys hopefully can get this to go..
Offline
That's not correct, before defining this alias $1 and $2 are expanded.
I cannot tell... I have no aliases defined with other aliases embedded. I guess I should have tried ![]()
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Thanks! That worked syntaxerrormmm ![]()
Offline