From: srikanth on 20 Apr 2010 07:47 Hi all, I have a problem while executing multiple command with in a Find command. Actually my requirement is to find a file in a specific directory and remove it and want to create a file with the same name which I have searched for. Here is what I am doing find Desktop/Test -name test -exec rm -rf {} \; -exec touch {}/test \; From the above command first command is executing successfully. But when comes to touch command it was not creating file. Is there any thing wrong under touch syntax or expressions? Can any one please help me. Also please suggest me if there are any easy way to do it.
From: pk on 20 Apr 2010 07:51 srikanth wrote: > Hi all, > I have a problem while executing multiple command with in a Find > command. Actually my requirement is to find a file in a specific > directory and remove it and want to create a file with the same name > which > I have searched for. Here is what I am doing > > find Desktop/Test -name test -exec rm -rf {} \; -exec touch {}/test \; > > From the above command first command is executing successfully. But > when comes to touch command it was not creating file. Is there any > thing wrong under touch syntax or expressions? Can any one please > help me. Also please suggest me if > there are any easy way to do it. use -exec sh -c 'all the commands you want with "$1"' sh {} \;
From: srikanth on 20 Apr 2010 08:06 On Apr 20, 4:51 pm, pk <p...(a)pk.invalid> wrote: > srikanth wrote: > > Hi all, > > I have a problem while executing multiple command with in a Find > > command. Actually my requirement is to find a file in a specific > > directory and remove it and want to create a file with the same name > > which > > I have searched for. Here is what I am doing > > > find Desktop/Test -name test -exec rm -rf {} \; -exec touch {}/test \; > > > From the above command first command is executing successfully. But > > when comes to touch command it was not creating file. Is there any > > thing wrong under touch syntax or expressions? Can any one please > > help me. Also please suggest me if > > there are any easy way to do it. > > use > > -exec sh -c 'all the commands you want with "$1"' sh {} \; I have tried with that alternative as well. But no luck. second command is not executing, i.e touch. Is there any problem with the syntax or the way i am using?
From: pk on 20 Apr 2010 08:11 srikanth wrote: > On Apr 20, 4:51 pm, pk <p...(a)pk.invalid> wrote: >> srikanth wrote: >> > Hi all, >> > I have a problem while executing multiple command with in a Find >> > command. Actually my requirement is to find a file in a specific >> > directory and remove it and want to create a file with the same name >> > which >> > I have searched for. Here is what I am doing >> >> > find Desktop/Test -name test -exec rm -rf {} \; -exec touch {}/test \; >> >> > From the above command first command is executing successfully. But >> > when comes to touch command it was not creating file. Is there any >> > thing wrong under touch syntax or expressions? Can any one please >> > help me. Also please suggest me if >> > there are any easy way to do it. >> >> use >> >> -exec sh -c 'all the commands you want with "$1"' sh {} \; > > I have tried with that alternative as well. But no luck. > second command is not executing, i.e touch. Is there any problem with > the syntax or the way i am using? It-s difficult to tell it you don't provide the exact command you used. If (guessing) that was something like find ... -exec sh -c 'rm -rf "$1";touch "$1"/test' sh {} \; obviously it's no wonder that it didn't work as you have to create the directory first. Otherwise, post the /exact/ command you used.
From: Ben Bacarisse on 20 Apr 2010 08:22 srikanth <srikanth007m(a)gmail.com> writes: > On Apr 20, 4:51 pm, pk <p...(a)pk.invalid> wrote: >> srikanth wrote: <snip> >> > Here is what I am doing >> >> > find Desktop/Test -name test -exec rm -rf {} \; -exec touch {}/test \; >> >> > From the above command first command is executing successfully. But >> > when comes to touch command it was not creating file. Is there any >> > thing wrong under touch syntax or expressions? Can any one please >> > help me. Also please suggest me if >> > there are any easy way to do it. >> >> use >> >> -exec sh -c 'all the commands you want with "$1"' sh {} \; > > I have tried with that alternative as well. But no luck. > second command is not executing, i.e touch. Is there any problem with > the syntax or the way i am using? How could anyone possibly know? :-) Please, at least post the command you used! -- Ben.
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: XTerm question: How to get current window title? Next: Splitting output to stderr |