0

Hello I would like to know how to generate a few files on the command lines. Say I am in a directory and

B:\>ls
201209  201210  201211  201212  201301  201302  201303  20130605_files_saved.txt  all_files_demande.txt  all_files_dsi.txt

Each directory contain a list of files

B:\>ls 201209 | head -n5
adifin1e_2012090107155700.bla
adifin1e_2012090404080200.bla
adifin1e_2012090506070000.bla
adifin1e_2012090607080400.bla
adifin1e_2012090707244900.bla

I know what I want to apply on each file

B:\>tail -n100 201209\adifin1e_2012090107155700.bla | grep DAT | cut -d, -f 11
"31-Aug-2012 21:41:12.950"
"31-Aug-2012 21:41:12.946"
"31-Aug-2012 21:41:12.950"
"31-Aug-2012 21:41:12.946"
"31-Aug-2012 21:41:12.950"

My question is how can I apply the same thing to each file in each directory and save the result as a file named with the same name than the file I am greping with another extension (say .res). I am using gnuWin32 on windows but basic functions like cut/tr/awk... are available

statquant
  • 13,672
  • 21
  • 91
  • 162

1 Answers1

1

perhaps

find . -type f -name "*.bla" | xargs gawk -F, "/DAT/ {print $11 > FILENAME \".res\"}"

I might not have the quoting right for a windows command shellprompt.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352