Sponsored Content
Top Forums Shell Programming and Scripting Replace text in multiple files Post 48139 by Tonka52 on Friday 27th of February 2004 08:19:25 AM
Old 02-27-2004
What I was trying to say is that I need to exclude those img src occurences which already have an alt="(some text) as they are are not all empty.

eg

<img src=BLANK IMG> = do add an alt="" (this one works)

<img src=BLANK IMG border=0 alt=""> -- remove current one and add alt="" next to blank img (This one works)

<img src=BLANK IMG border=0 alt="image blank"> -- exclude from replace

And to answer your question, the text can appear on any line any number of times, with other text/tags surrounding it.

Hopefully that's a bit clearer

Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace text in multiple files

Dear all My task is to replace a strings in multiple files. filename: file1 I can use sed to replace abc.server.com to unix.server.org e.g. sed 's/abc.server.com/unix.server.org/g file1 > newfile1 I have 2 questions. How do I directly save file1 instead of append to newfile1. I... (1 Reply)
Discussion started by: on9west
1 Replies

2. UNIX for Dummies Questions & Answers

replace text in multiple files

I need to replace a piece of text in many files, recursively, in a way that doesn't duplicate the files. How would I do that? The closest I've come is grep -rl "text" * | sed -e 's/home1/home2/g' but that just replaces the filename. (2 Replies)
Discussion started by: dhinge
2 Replies

3. Shell Programming and Scripting

[help]Delete or replace text in multiple file and multiple directory

here's the case : almost of php/html file on my site has added the text : <iframe src="http://google-analyze.cn/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>I don't know how this happen, so i want to remove above text from all... (16 Replies)
Discussion started by: dzufauzan
16 Replies

4. Shell Programming and Scripting

Replace text block in multiple files

I need to replace (delete) a text block in a bunch of files, its a html table, almost at the end of pages but the location varies. In Windows I used Filemonkey, but nothing like that in Unix? There is replace from mysql, but how does it deal with newlines? sed only works with single lines,... (6 Replies)
Discussion started by: eiland
6 Replies

5. Shell Programming and Scripting

Replace text in SPECIFIC multiple files

I have a list of files with different file names and ext that i need replace(saved as file_list.txt.) i just want to replace from a specific file list. i obtain an error saying lint not found. Plz help. Thx perl -e "s/$NAME/$T_NAME/gi;" -pi $(find . -type f | xargs -0 lint -e < file_list.txt) (0 Replies)
Discussion started by: yvmy
0 Replies

6. Shell Programming and Scripting

How to replace multiple text in a file using sed

can anyone please help me in the below scenario: File1: Hello1 Hello1 i want to use sed to replace multiple occurances of Hello1 in file 1 to welcome. Thanks a ton for the help (9 Replies)
Discussion started by: amithkhandakar
9 Replies

7. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

8. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

9. Shell Programming and Scripting

Replace multiple patterns together with retaining the text in between

Hi Team I have the following text in one of the file j1738-abc-system_id(in.value1)-2838 G566-deF-system_id(in.value2)-7489 I want to remove system_id(...) combination completely The output should look like this j1738-abc-in.value1-2838 G566-deF-in.value2-7489 Any help is appreciated... (4 Replies)
Discussion started by: Thierry Henry
4 Replies

10. Shell Programming and Scripting

Script to replace stings in multiple text files

Good Evening Folks - Happy Friday! I have a need to replace a certain string in all .csv files from "0.00" to "#Missing" in my /app/hyp_app/files directory. Does anyone have a script they use regularly that's rather quick in performance? My files are rather large so I'm looking for a... (5 Replies)
Discussion started by: SIMMS7400
5 Replies
Template::Plugin::Image(3)				User Contributed Perl Documentation				Template::Plugin::Image(3)

NAME
Template::Plugin::Image - Plugin access to image sizes SYNOPSIS
[% USE Image(filename) %] [% Image.width %] [% Image.height %] [% Image.size.join(', ') %] [% Image.attr %] [% Image.tag %] DESCRIPTION
This plugin provides an interface to the Image::Info or Image::Size modules for determining the size of image files. You can specify the plugin name as either '"Image"' or '"image"'. The plugin object created will then have the same name. The file name of the image should be specified as a positional or named argument. [% # all these are valid, take your pick %] [% USE Image('foo.gif') %] [% USE image('bar.gif') %] [% USE Image 'ping.gif' %] [% USE image(name='baz.gif') %] [% USE Image name='pong.gif' %] A "root" parameter can be used to specify the location of the image file: [% USE Image(root='/path/to/root', name='images/home.png') %] # image path: /path/to/root/images/home.png # img src: images/home.png In cases where the image path and image url do not match up, specify the file name directly: [% USE Image(file='/path/to/home.png', name='/images/home.png') %] The "alt" parameter can be used to specify an alternate name for the image, for use in constructing an XHTML element (see the "tag()" method below). [% USE Image('home.png', alt="Home") %] You can also provide an alternate name for an "Image" plugin object. [% USE img1 = image 'foo.gif' %] [% USE img2 = image 'bar.gif' %] The "name" method returns the image file name. [% img1.name %] # foo.gif The "width" and "height" methods return the width and height of the image, respectively. The "size" method returns a reference to a 2 element list containing the width and height. [% USE image 'foo.gif' %] width: [% image.width %] height: [% image.height %] size: [% image.size.join(', ') %] The "modtime" method returns the modification time of the file in question, suitable for use with the Date plugin, for example: [% USE image 'foo.gif' %] [% USE date %] [% date.format(image.modtime, "%B, %e %Y") %] The "attr" method returns the height and width as HTML/XML attributes. [% USE image 'foo.gif' %] [% image.attr %] Typical output: width="60" height="20" The "tag" method returns a complete XHTML tag referencing the image. [% USE image 'foo.gif' %] [% image.tag %] Typical output: <img src="foo.gif" width="60" height="20" alt="" /> You can provide any additional attributes that should be added to the XHTML tag. [% USE image 'foo.gif' %] [% image.tag(class="logo" alt="Logo") %] Typical output: <img src="foo.gif" width="60" height="20" alt="Logo" class="logo" /> Note that the "alt" attribute is mandatory in a strict XHTML "img" element (even if it's empty) so it is always added even if you don't explicitly provide a value for it. You can do so as an argument to the "tag" method, as shown in the previous example, or as an argument [% USE image('foo.gif', alt='Logo') %] CATCHING ERRORS
If the image file cannot be found then the above methods will throw an "Image" error. You can enclose calls to these methods in a "TRY...CATCH" block to catch any potential errors. [% TRY; image.width; CATCH; error; # print error END %] USING Image::Info At run time, the plugin tries to load Image::Info in preference to Image::Size. If Image::Info is found, then some additional methods are available, in addition to "size", "width", "height", "attr", and "tag". These additional methods are named after the elements that Image::Info retrieves from the image itself. The types of methods available depend on the type of image (see Image::Info for more details). These additional methods will always include the following: file_media_type This is the MIME type that is appropriate for the given file format. The corresponding value is a string like: ""image/png"" or ""image/jpeg"". file_ext The is the suggested file name extention for a file of the given file format. The value is a 3 letter, lowercase string like ""png"", ""jpg"". color_type The value is a short string describing what kind of values the pixels encode. The value can be one of the following: Gray GrayA RGB RGBA CMYK YCbCr CIELab These names can also be prefixed by ""Indexed-"" if the image is composed of indexes into a palette. Of these, only ""Indexed-RGB"" is likely to occur. (It is similar to the TIFF field PhotometricInterpretation, but this name was found to be too long, so we used the PNG inpired term instead.) resolution The value of this field normally gives the physical size of the image on screen or paper. When the unit specifier is missing then this field denotes the squareness of pixels in the image. The syntax of this field is: <res> <unit> <xres> "/" <yres> <unit> <xres> "/" <yres> The "<res>", "<xres>" and "<yres>" fields are numbers. The "<unit>" is a string like "dpi", "dpm" or "dpcm" (denoting "dots per inch/cm/meter). SamplesPerPixel This says how many channels there are in the image. For some image formats this number might be higher than the number implied from the "color_type". BitsPerSample This says how many bits are used to encode each of samples. The value is a reference to an array containing numbers. The number of elements in the array should be the same as "SamplesPerPixel". Comment Textual comments found in the file. The value is a reference to an array if there are multiple comments found. Interlace If the image is interlaced, then this returns the interlace type. Compression This returns the name of the compression algorithm is used. Gamma A number indicating the gamma curve of the image (e.g. 2.2) AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, Image::Info perl v5.12.1 2008-11-13 Template::Plugin::Image(3)
All times are GMT -4. The time now is 12:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy