bash script path issue - how to pass a path as a string to a variable
I'm trying to pass a path as a string to an array, but its evaluating it as a command instead. (sorry im new at this, forgive me :)
I want to take the literal string "/mnt/accounts/user/temp/*.jpg" and assign it to an array{1}, but when i echo the array variable, it displays it as pic1.jpg pic2.jpg pic3.jpg etc etc ... I just want it to be the actual text "/mnt/accounts/user/temp/*.jpg" which i will be combining with other text to create a longer path elsewhere in the code. Is there some special quotes or something i need to put around it? thx PiN |
Quote:
(not the "backticks": `bla bla`) |
Perhaps i'm combining the two strings together incorrectly, im still getting the list of all the jpg's
What is the proper way to combine to strings from 2 variables together? eg: string1="/mnt/accounts/user/" string2="test" string3=$string1$string2 expected: "/mnt/accounts/user/test" and that works, but if i combine string1="/mnt/accounts/user/" string2='*.jpg' string3=$string1$string2 i get a list of .jpg's using .jpg works, so is there some special character you have to use if you want to print a * instead of using it as a wildcard? just need need to append *.jpg to the end of a string |
what are you trying to do?
you can use a for loop Code:
for file in $.jpg Code:
$ A=(*.mp3) |
Quote:
Code:
~/tmp$ f=t.* |
I'm not certain if you want a string: '/mnt/accounts/user/temp/*.jpg'
or an array variable: /mnt/accounts/user/temp/picture1.jpg /mnt/accounts/user/temp/picture2.jpg /mnt/accounts/user/temp/picture3.jpg If you want the latter, you can use: pictures=(/mnt/accounts/user/temp/*.jpg) Then each jpeg filename (including the path) will be in an element of a zero based array variable pictures. E.G. ${pictures[1]} will contain '/mnt/accounts/user/temp/picture2.jpg'. If you want the former, either escape the asterisk \* or enclose the string in single quotes. |
All times are GMT -5. The time now is 01:25 AM. |