Skip to main content
Mod Moved Comments To Chat
added 199 characters in body
Source Link
d-cubed
  • 204
  • 3
  • 21

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")

which might then be combined into something like this:

for dir in aa bb cc dd; do for file in EA_sing EA_ska EA_tat; do for myfile in $(ls $dir/$file*);do echo "parsing $myfile"; cat $myfile | sed -e "s/\(.*\)/$dir,\1/g" >> $(echo "$file\_combined.csv"); done; done; done

Or more to the point:

for dir in $(ls -d */); do for file in $(ls $dir*csv); do echo "this is my file $file"; cat $file|sed -e "s|\(.*\)|$(echo $dir|sed -e 's/\///g'), \1|g";done; done

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")

which might then be combined into something like this:

for dir in aa bb cc dd; do for file in EA_sing EA_ska EA_tat; do for myfile in $(ls $dir/$file*);do echo "parsing $myfile"; cat $myfile | sed -e "s/\(.*\)/$dir,\1/g" >> $(echo "$file\_combined.csv"); done; done; done

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")

which might then be combined into something like this:

for dir in aa bb cc dd; do for file in EA_sing EA_ska EA_tat; do for myfile in $(ls $dir/$file*);do echo "parsing $myfile"; cat $myfile | sed -e "s/\(.*\)/$dir,\1/g" >> $(echo "$file\_combined.csv"); done; done; done

Or more to the point:

for dir in $(ls -d */); do for file in $(ls $dir*csv); do echo "this is my file $file"; cat $file|sed -e "s|\(.*\)|$(echo $dir|sed -e 's/\///g'), \1|g";done; done
added 278 characters in body
Source Link
d-cubed
  • 204
  • 3
  • 21

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")

which might then be combined into something like this:

for dir in aa bb cc dd; do for file in EA_sing EA_ska EA_tat; do for myfile in $(ls $dir/$file*);do echo "parsing $myfile"; cat $myfile | sed -e "s/\(.*\)/$dir,\1/g" >> $(echo "$file\_combined.csv"); done; done; done

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")

which might then be combined into something like this:

for dir in aa bb cc dd; do for file in EA_sing EA_ska EA_tat; do for myfile in $(ls $dir/$file*);do echo "parsing $myfile"; cat $myfile | sed -e "s/\(.*\)/$dir,\1/g" >> $(echo "$file\_combined.csv"); done; done; done
Source Link
d-cubed
  • 204
  • 3
  • 21

This is an off the cuff answer:

for dir in $(ls ); do echo " $dir - this is the directory"; for csv in $(ls $dir/*csv); do cat $csv|sed -e "s/\(.*\)/$dir, \1/g"; done;  done

You could then add options to specify file names, e.g.

for myfile in EA_sing EA_ska EA-tat; do for csv in $(ls $dir/$myfile*)...

and then pipe them to a file of your choice, e.g.

do cat $csv|sed -e "s/\(.*\)/$dir, \1/g" >> $(echo "$myfile_complete.csv")