I want to put multiple filepaths as a string in bash script, so I can pass this string to another program. When I concatenate these filepaths I get the error: No such file or directory. Bash has to tread this filepath as a string instead of a file...
Im concatenating this way:
all=""
for path in $dir/*; do
filePath="$path/file.txt"
$all="$all I=$filePath"
done
echo $all
How can I get this output?
I=first/file.txt I=second/file.txt etc.
Is just your syntax wrong:
all=""
for path in $dir/*; do
filePath="$dir/file.txt"
all="$all I=$filePath" #without $
done
echo $all
Maybe you meant to use path
? And don't use $ as a prefix in assignments.
all=""
for path in $dir/*; do
filePath="$path/file.txt"
all="$all I=$filePath"
done
echo $all
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.