page

Nov 12, 2018

How to read a file into a variable in shell?


https://stackoverflow.com/questions/7427262/how-to-read-a-file-into-a-variable-in-shell


1. make file name list

ls | grep .gz > file_name_list.txt


2.  read file into shell variable & do 'for'

value=$(<file_name_list.txt)
for name in $value
do
/program_path/program -i /file_path/${name}
done

No comments:

Post a Comment