Below shows what I'm getting when I'm in the shell trying to reference a filename that has a space in the name.
#===================================
$>ls *2021.txt
$> 'JAN 2021.txt' 'FEB 2021.txt' 'MAR 2021.txt'
$> cat files.txt
JAN 2021.txt
FEB 2021.txt
MAR 2021.txt
$> cat ascript.txt
for i in `cat files.txt`
do
echo $i
done
$> ./ascript.txt
JAN
2021.txt
FEB
2021.txt
MAR
2021.txt
$>
#===================================
As you can see, the variable $i in the shell script uses the space in the file name as a delimiter. Thus, I cannot get the entire filename in the variable $i in the for loop for each row in the files.txt file. Anyone know how I can reference every part of the filename in the for loop per each line?
I'm ultimately trying to determine from the filename the month and the year within the for loop to create variables relating to the month and the year. Example: to evaluate the string JAN in the filename to '01', FEB to '02' and the 2021 to '2021', etc. These variables will then be used to create a date string that will be inserted as a column for each row in each of the respective files to denote that all records within a file is from that dated file.
Sorry for the lengthy post, but, I'm trying to be as clear as possible.
Thanks in advance!!