LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-09-2008, 11:14 PM   #1
Juan Pablo
LQ Newbie
 
Registered: Mar 2007
Distribution: LFS, Gentoo and Ubuntu
Posts: 8

Rep: Reputation: 0
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

Last edited by Juan Pablo; 07-09-2008 at 11:15 PM.
 
Old 07-09-2008, 11:21 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 62
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. ]

Last edited by Mr. C.; 07-09-2008 at 11:26 PM. Reason: Misread
 
Old 07-09-2008, 11:24 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
sed -i 's#^#http://images.example.org/#' file
 
Old 07-09-2008, 11:26 PM   #4
Juan Pablo
LQ Newbie
 
Registered: Mar 2007
Distribution: LFS, Gentoo and Ubuntu
Posts: 8

Original Poster
Rep: Reputation: 0
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!
 
Old 07-09-2008, 11:31 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 62
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to change String using sed with a string \/home\/user\/Desktop icecoolcorey Programming 10 06-13-2008 12:32 AM
Shell Script: Delete lines til string found or until particular string. bhargav_crd Linux - General 3 12-21-2007 12:14 AM
The method contains(String) is undefined for the type String sampada Programming 1 06-30-2007 11:02 AM
Rewrite rule with query string in the pattern string basahkuyup Linux - Newbie 2 10-17-2006 03:06 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 02:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration