I have bunch of .sv files in the following directory /home/vs/vs_work2/Miss.Chim_DEPBand I want to run the following command with each file name from the above directory
make sim TB=depb/sim/utb/epb_uvm_tb.json TC= **USE_FILE_NAME_From_ABOVE_Directory**
and keep the result of each file after the run into a separate file along with its files name that it ran with.
This what I tried
#!/bin/bash
FILES=/home/vs/vs_work2/Miss.Chim_DEPB/*.sv
NUM_OF_FILES= ls /home/vs/vs_work2/Miss.Chim_DEPB/*.sv | wc -l # this will lst number of files in that directory
declare -a vendec[NUM_OF_FILES] # declared array "-a" is used for index array
arraylength=${#vendec[@]}
for f in $FILES
do
#echo -n "" > vendec[*].txt #to empty file
vendec[i]
echo "$f" >> vendec.txt
done
You can run the following one-liner:
It will list all
.svfiles in/home/vs/vs_work2/Miss.Chim_DEPB/and then, for each file, it will run themake sim TB=depb/sim/utb/epb_uvm_tb.json TC={}command with the{}placeholder being replaced with a file from the directory, and if that succeeds, it will write the name of the file at the end of thevendec.txtfile.Note that you can use the
-Poption ofxargsto have multiple runs of themake sim ....command in parallel.