LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Merging a one string to various others (https://www.linuxquestions.org/questions/programming-9/merging-a-one-string-to-various-others-654741/)

Juan Pablo 07-09-2008 10:14 PM

Merging a one string to various others
 
I have a list of files like this

00023.jpg
00067.jpg
00012.jpg
00098.jpg

on a file

I need to add the http://images.example.org/ string before each of them
I am doing this in bash BTW
Any clue?

Thanks in advance

Mr. C. 07-09-2008 10:21 PM

Code:

for file in [0-9]*.jpg ; do
  echo "http://images.example.org/$file"
done

[ edit: Oops - thought that said have files, not have a list of files. - sorry. ]

jschiwal 07-09-2008 10:24 PM

sed -i 's#^#http://images.example.org/#' file

Juan Pablo 07-09-2008 10:26 PM

Thanks Mr.C!

However my list of file doesn't have an order, but I have the complete list on a file. I tried

for file in īcat filelistī; do
echo "$url$file"
done

Thanks!

Mr. C. 07-09-2008 10:31 PM

If you have a list of files in a file, use jschiwal's better solution. I misread your question. If you have files in a directory, then what I gave will work. You did a nice job adapting my mis-answer to your situation though!


All times are GMT -5. The time now is 06:15 PM.