I'm using bash on Windows (distributed along with msysgit) to zip log files - one archive per date. Problem is, following script does not work and I have no idea why. Cut is here to get part of the filename that corresponds to a date the log was written.
find . -type f -name '*.log' | cut -c3-12 | head -n 5 | xargs -I common printf "%s%s\n" common "*.log" | xargs -I fg tar cvzf hello.tgz fg
Before last step, each line looks like this - 2014-07-04*.log
At the last step it gives me output like this:
tar: 2014-07-01*.log: Cannot stat: No such file or directory
I suspect it's because of a newline at the end, because when I call tar command by hand it works fine. Any ideas what I missed? I read some of the similar answers, but they don't seem to apply in my case. Archive name is for example, later I'd make it more descriptive.