This series of commands edits idea.js and exports it as idea.csv;
sed -n '/^get\.idea/s/^.*(\(.*\)).*/\1/ p' idea.js |
awk -F, 'BEGIN {print "idea, description";OFS=","} (NR % 2 ) == 1
{save=$2} (NR % 2) == 0 {print save, $2}' > idea.csv
And what I need to do is run exactly the same commands but using find
to search in multiple files with the same idea.js name which are in multiples directories, exporting each of those files in the same directory that idea.js was found.
I tried in many ways but I get different errors.
Here the result is not what's expected:
find . -type f -name "idea.js" \( \
-exec sed -n '/^get\.idea/s/^.*(\(.*\)).*/\1/ p' idea.js {} \; -o \
-exec true \; \) \
-exec awk -F, 'BEGIN {print "idea, description";OFS=","} (NR % 2 ) == 1
{save=$2} (NR % 2) == 0 {print save, $2}' > idea.csv {} \;
And here:
find . -type f -name "idea.js" \(
-exec sed -n '/^get\.idea/s/^.*(\(.*\)).*/\1/ p' idea.js |
awk -F, 'BEGIN {print "idea, description";OFS=","} (NR % 2 ) == 1
{save=$2} (NR % 2) ==0 {print save, $2}' > idea.csv {} \)
I get this error:
idea, description
awk: cannot open {} (No such file or directory)
find: missing argument to `-exec'
Try 'find --help' for more information.
I would like learn how to do this directly from the command line, and as a script, to be executed this way:
$ sh script.sh
I appreciate the help.