Sponsored Content
Top Forums Shell Programming and Scripting Truncate the content within alt attribute to first 250 characters. Post 302285183 by cfajohnson on Saturday 7th of February 2009 04:28:17 PM
Old 02-07-2009

This truncates the alt attribute by item, rather than characters:

Code:
altcheck() #@ USAGE: altcheck [max]
{ #@ Truncate the alt attribute in $line to $max characters
  max=${1:-250}
  right=${line#*alt=\"}
  left=${line%"$right"}
  alt=${right%%\"*}
  right=${line#*"$alt"}
  while [ ${#alt} -gt $max ]
  do
    alt=${alt% &*}
  done
  line=$left$alt$right
}

while IFS= read -r line
do
  case $line in
    *"<img"*alt=*) altcheck ;;
  esac
  printf "%s\n" "$line"
done < "$FILE"

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

alt boot

ok guys, I have been given a big project, I need to implement alt boot on over 40+ servers, mainly solaris 8 and AIX 4.3, AIX 5.1. A couple of questions 1)can someone describe alt boot, my take is that if the primary disk fails(disk with root filesystems), this altboot disk takes over 2)can... (4 Replies)
Discussion started by: csaunders
4 Replies

2. UNIX for Dummies Questions & Answers

Truncate last <n> characters from a file

I am trying to concatenate 2 files, but before concatenation, I would like to strip off the final character from the first file. The final character is a form feed (ascii 012 / hex 0C) and there will be an unknown number of these characters in the file. It is only the very last one which I want... (1 Reply)
Discussion started by: Gwailo88
1 Replies

3. UNIX for Dummies Questions & Answers

Alt - Characters

in Win, one can use the Alt + 3-digit numeric code combination to spawn any ASCII character. Linux, OTOH has Ctrl-Shift-U + alphanumeric code combination to spawn any UNICODE character. bottom line: I'd like to be able to do what Win can do, please. I was told it was possible, but made... (5 Replies)
Discussion started by: ialoq
5 Replies

4. Shell Programming and Scripting

Truncate file name to 40 characters

Hello all. I would like to make a script (or two shell scripts) that will do the following. I need the maximum file name and directory name to be 38 characters long. As well, if shortening the file name ends up making all of the files in that directory have the same name, then I would like... (9 Replies)
Discussion started by: marcozd
9 Replies

5. Shell Programming and Scripting

how to delete special characters from the file content

Hello Team, Any one suggest how to delte the below special character from a file which is having one column 10 rows of same below content. ---------------------------------------- Kosten|bersicht gemd_ ' =Welche Kosten kvnnen... (2 Replies)
Discussion started by: kanakaraju
2 Replies

6. Shell Programming and Scripting

Truncate all characters and numbers in string - using perl

hi, I have an data from file where it has 20110904 234516 <<hdd-10#console|0c.57,passed,5,28,READ,0,20822392,8,5,4,0,40,0,-1,0,29909,25000,835,3.3,0,0,0,0,implied,0,0,2011/9/5-2:3:17,2011/9/5-2:3:47,X292_0F15,TAP ,NQ09,J40LTG\r\r\n I want to remove characters till #console| i.e want... (1 Reply)
Discussion started by: asak
1 Replies

7. Shell Programming and Scripting

Matching a pattern 250 characters up and down stream

hii all i have a file a which contains some thing like this strand smthg position + yyx 3020 - yyw 10,000 now i have another file (file2) which contains the data starting from 1 to n positions i want to refer first file if + ... (4 Replies)
Discussion started by: anurupa777
4 Replies

8. AIX

alt clone

I have two identical systems p740 with 2 lpars in each server. I dont want to install os from scratch on each lpar neither I want to use nim nor mksysb. Will it work perfectly if I install a fresh OS on 1 lpar and do alt disk clone for other lpras. My each lpar is having 2 physical disks. Now if... (2 Replies)
Discussion started by: vjm
2 Replies

9. Shell Programming and Scripting

How to truncate a string to x number characters?

Hello: I have a large file which contains lines like the following: 1/t123ab, &Xx:1:1234:12345:123456@ABCDEFG... at -$100.00% /t is a tab, spaces are as indicated the string "&Xx:1:1234:12345:123456$ABCDEFG..." has a slightly variable number of numbers and letters, but it always starts... (9 Replies)
Discussion started by: Tectona
9 Replies
Geo::GoogleEarth::Pluggable::Plugin::Default(3pm)	User Contributed Perl Documentation	 Geo::GoogleEarth::Pluggable::Plugin::Default(3pm)

NAME
Geo::GoogleEarth::Pluggable::Plugin::Default - Geo::GoogleEarth::Pluggable Default Plugin Methods METHODS
Methods in this package are AUTOLOADed into the Geo::GoogleEarth::Pluggable::Folder namespace at runtime. CONVENTIONS
Plugin Naming Convention: Geo::GoogleEarth::Pluggable::Plugin::CPANID (e.g. "MRDVT") Object Naming Convention: Geo::GoogleEarth::Pluggable::Contrib::"$method" (e.g. Point, CircleByCenterPoint) You only need to have one plugin pointing to all of your contributed objects. The package should be named after the plugin not the objects since there is a many to one relationship. (e.g. Geo-GoogleEarth-Pluggable- Plugin-MRDVT) Point Constructs a new Placemark Point object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction. my $point=$folder->Point(name=>"My Placemark", lat=>38.897607, lon=>-77.036554, alt=>0); LineString $folder->LineString(name=>"My Placemark", coordinates=>[ [lat,lon,alt], {lat=>$lat,lon=>$lon,alt=>$alt}, ]); LinearRing $folder->LinearRing(name=>"My Placemark", coordinates=>[ [lat,lon,alt], {lat=>$lat,lon=>$lon,alt=>$alt}, ]); TODO
Need to determine what methods should be in the Folder package and what should be on the Plugin/Default package and why. BUGS
Please log on RT and send to the geo-perl email list. SUPPORT
DavisNetworks.com supports all Perl applications including this package. AUTHOR
Michael R. Davis (mrdvt92) CPAN ID: MRDVT COPYRIGHT
This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
Geo::GoogleEarth::Pluggable::Contrib::Point, Geo::GoogleEarth::Pluggable::Contrib::LineString, Geo::GoogleEarth::Pluggable::Contrib::LinearRing perl v5.14.2 2010-12-27 Geo::GoogleEarth::Pluggable::Plugin::Default(3pm)
All times are GMT -4. The time now is 08:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy