LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   >> , how to use ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-286464/)

thanhVic 02-05-2005 02:07 AM

>> , how to use ?
 
I have a file:

$ cat new
face.jpg
owl-face.jpg
man-face.jpg

normally, if we want to append a character or a file:

$ echo "anything.jpg" >> new

$ cat new
face.jpg
owl-face.jpg
man-face.jpg
anything

my question is how to append "anything" any where I want ;

face.jpg anything
owl-face.jpg
man-face.jpg
anything

or

face.jpg
anything owl-face.jpg
man-face.jpg
anything

thanks for helping,

win32sux 02-05-2005 02:22 AM

i believe you'd use sed for this, but you'd have to specify what you mean by "anywhere"... like, perhaps you wanna insert the text after a certain line number, or maybe after a certain text pattern, etc...

http://www.google.com/linux?hl=en&lr...=Google+Search

just my two cents...

thanhVic 02-05-2005 02:33 AM

Well, I know how to do that with sed. But I wonder if there is any way to do it with bash?

Quote:

perhaps you wanna insert the text after a certain line number, or maybe after a certain text pattern
I meant I can put a tring anywhere I want to a text file

thanhVic 02-05-2005 02:38 AM

My problem is I have a file "new"

$ cat new
face.jpg
owl-face.jpg
man-face.jpg

How I make this file become a html file ?
<html>
<body>
<table>
<tr><td><img src=face.jpg></td>
<tr><td><img src=owl-face.jpg></td>
<tr><td><img src=man-face.jpg></td>
</table>
</body>
</html>

bash only,
thanks,

win32sux 02-05-2005 03:15 AM

Quote:

Originally posted by thanhVic
Well, I know how to do that with sed. But I wonder if there is any way to do it with bash?
if you already know how to do this with sed, then you have everything you need...

you can't do it "just with bash" as bash is just a shell and needs access to commands such as cat, grep, gawk, sed, etc. to be able to actually do stuff like this...

win32sux 02-05-2005 06:19 PM

Quote:

Originally posted by thanhVic
My problem is I have a file "new"

$ cat new
face.jpg
owl-face.jpg
man-face.jpg

How I make this file become a html file ?
<html>
<body>
<table>
<tr><td><img src=face.jpg></td>
<tr><td><img src=owl-face.jpg></td>
<tr><td><img src=man-face.jpg></td>
</table>
</body>
</html>

bash only,
thanks,

i see what you mean... well, i'd imagine you could use variables, so that when you echo the text the variables would be replaced by the actual filename, or something like that...

for example, let's say you make face.jpg equal to $jpg-001, then the line "<tr><td><img src=face.jpg></td>" could be printed like:

Code:

echo "<tr><td><img src=$jpg-001></td>"


All times are GMT -5. The time now is 08:09 AM.