Оба ваших примера, как показано, верны. Обновите свой вопрос новой информацией (например, используются ли на самом деле именно те имена каталогов?) Или предоставьте доказательства для утверждения "не работает".
bash-4.1$ mkdir my_folder
bash-4.1$ my_var=my_folder
bash-4.1$ cd $my_var
bash-4.1$ pwd
/home/jdoe/my_folder
bash-4.1$ cd ..
bash-4.1$ my_var="my_folder"
bash-4.1$ cd $my_var
bash-4.1$ pwd
/home/jdoe/my_folder
bash-4.1$
# script.awk
BEGIN {
FPAT = "[^\"]+"
}
{
# the first if is to avoid processing title row and rows that do not contain fields
if (NF > 1) {
# the third field is the linking page column; the second field is a comma
if ($3 != "" && $1 $3 in unique_linking_pages == 0) {
unique_linking_pages[$1 $3]
unique_linking_page_counts[$1]++
}
# the fifth field is the domain column; the fourth field is a comma
if ($5 != "" && $1 $5 in unique_domains == 0) {
unique_domains[$1 $5]
unique_domain_counts[$1]++
}
# in case of empty fields in columns 2 and or 3 of the input file,
# this ensures that all the dates are recorded
dates[$1]
}
}
END {
printf "Date, Unique Linking Page Count, Unique Domain Count\n"
for (date in dates)
output = output date " | " unique_linking_page_counts[date] " | " unique_domain_counts[date] "\n"
system("column -t -s '|' <<< '" output "'")
}