I am trying to store some variables in shell command to run some process using thos variables:
for i in $(find . -type f -path '*folder*/*.json'); do
echo $i
basename=${i##*/}
FILENAME=$(cut -d'_' -f2- "$basename")
PAR1="${FILENAME%%.*}_label"
PAR2="${FILENAME%%.*}.format"
SUFFIX= `echo $basename rev | cut -d'_' -f 1 | rev`
done
But variables FILENAME AND SUFFIX doesn't do what expected
i.e. (expected values)
i=./path/to/1_test_file.json
basename=1_test_file.json
FILENAME=test_file.json
PAR1=test_file_label
PAR2=test_file.format
SUFFIX= file.json
I have checked in similar post with similar questions here, which suggest similar approach to what I did but doesnt work...