bash - An awk script to run over different files -
i have wrote script: looking.awk searches particular data in file:
{if ($0 ~ "neighbors of non-equivalent atoms") {flag=1}}; # if current line of file begins string, asign flag=1 {if (flag==1) {if ($0 ~ $1==1 && $2=="ca" && $6==14 && $7=="o"){line=$0; exit} } }; # here searching "1 ca" on each line end{vol=filename; # filename is: "c_from_v_273_008245_50_neighbours_symremo.out" # intention end new file 2 columns: # "volume" , "distance". # notice filename contains volume: 273.008245 gsub("^.*_v_","",vol); gsub("_",".",vol); gsub(".50.neighbours.symremo.out"," ",vol); # substitutions make "c_from_v_273_008245_50_neighbours_symremo.out" # "273.008245" # output of running: # search_for_distance.awk -f c_from_v_273_008245_50_neighbours_symremo.out # following: # 273.008245 1 ca 1 2.4055 4.5458 7 o 0 0 0 # so, need take line , extract column "4". # done "split" command: {split(line,array," ")} print vol,array[4]} the script located in current folder .
i have several folders , files in i'd run script.
these paths:
.../cvolopts_and_f9_for_labels_v_247_803181/c_v_247_803181_50_neighbours_symremo.out .../cvolopts_and_f9_for_labels_v_250_532893/c_v_247_803181_50_neighbours_symremo.out . . . i running script as:
awk -f looking.awk ../cvolopts*_v*/calcite_iiib*v*50_n*_symremo.out > ./d_ca-1_o_7/data.dat but in data.dat generated there result of script on .../cvolopts_and_f9_for_labels_v_247_803181/c_v_247_803181_50_neighbours_symremo.out file
how can run script looks inside .out files in paths?
thank help
how can run script looks inside .out files in paths?
find /base/directory/to/search -type f -name "*.out" -exec awk -f /path/to/looking.awk {} >>/path/to/d_ca-1_o_7/data.dat \; what happening here?
- we set
/base/directory/to/searchbase directory search. - we ask
findfind filestypedirective. - we wish files ending
.outset name*.out.*here wild-card expand possible outputs filter using criteria mentioned in 1 & 2. -execused apply commands on filtered output. pipe process output of find. @ same time different normal pipe (|) in formatting appliedfind-say-print0- retained exec. formatting done in cases process non-standard files,for example, files new-lines or special characters. use{}pass formatted string command.- we
awkstuff , append resultsdatfile.
Comments
Post a Comment