Author: Stan Eisenstat
Subject: Re: [Cs323] -exec echo {} > foo
Date: Sunday, 06 Sep 2020, 09:30:35
> Message Posted By: Anonymous > > When I run: > > find -type f -print -exec echo {} > foo \; > > I expect every file name to be printed on the command line AND written to > the file 'foo'. However, what happens instead is that each file name is > written twice to 'foo', and nothing is printed on the command line. Is > this intended? Shouldn't only what is under -exec being piped to 'foo', > and not the actual output of find? As you can see by running % echo -type f -print -exec echo {} > foo \; because the > is not escaped, bash treats it and the next argument "foo" as signifying output redirection and does not pass them to the command. Thus in effect the command is % find -type f -print -exec echo {} \; > foo which explains the behavior you are seeing. --Stan-PREV INDEX NEXT