0

I have one file that contains 55 data points correspond to each file (55 files) in the directory. How can I make a loop that reads lines from files and used for the only corresponding file? such as

Lag data
0 
0 
0.2 
0.4 
Files names in directory
132_bhz.sac 
142_bhz.sac
152_bhz.sac  
162_bhz.sac

what i want to do

Get value from lag data and used in corresponding files and complete the loop
e.g
get 0 and used 132.bhz.sac complete the loop
get 0.4 and used 164.bhz.sac as we same numbers of values and files.

I tried this way, but it uses one value for every file but I want that it should read only one and later complete the loop and get another value from the file

here is my attempt:

while read line && [ "$line" != "" ];

do 
echo $line
lagtime=$(echo $line |awk '{print $1}') ;
echo $lagtime "lag"

input_dir=~/Aqeel_practice/NCCF_land_Data/Land_Data/ML_G7
    for stnm in $input_dir/ML65/2020/*
    do
    #cd $stnm
    echo $stnm 
       done
done <lag_data.txt
2
  • 1
    It is not clear how you want the files to be processed. Provide an example. May 18, 2021 at 10:35
  • How to map data in first file and filenames? May 18, 2021 at 14:20

1 Answer 1

0

Thanks, dear, I was repeating a mistake. I SOLVED this problem by combining the file names and lag time in one file. SO when it will read the line, it will also get the respective file name and use it in the loop,

Thank you so much for your support.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .