Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 01 Sep 2014, 08:35
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Verify if a string is a valid UTF-8 string? [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [22 Posts]   Goto page: Previous 1, 2
Author Message
don570


Joined: 10 Mar 2010
Posts: 3261
Location: Ontario

PostPosted: Sat 09 Mar 2013, 15:47    Post subject:  

It's possible to do stream editing (SED) on one line by using the semi-colon.
It might speed up the script as well.

Code:


sed -i "s%<b>%%g;" /tmp/report-video_
sed -i "s%</b>%%g" /tmp/report-video_

sed -i "s%<b>%%g;s%</b>%%g" /tmp/report-video_


Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1825
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 09 Mar 2013, 17:14    Post subject:  

Hello don570,
Yes, it is much better! This is the way we learn, little by little... Thank you! I will have to revise most of the scripts I made, because since the first one, I learnt many small tricks like this one: for sure, they will be less heavy and faster! Wink

Cordialement.
Back to top
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1825
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 16 Mar 2013, 11:33    Post subject:  

Bonjour,
Following the code lines above, I replaced:
Code:
func () {
sed -i "s%<b>%%g" /tmp/report-video_
sed -i "s%</b>%%g" /tmp/report-video_
sed -i "s%millimeters%$(gettext 'millimeters')%g" /tmp/report-video_
sed -i "s%planes%$(gettext 'planes')%g" /tmp/report-video_
sed -i "s%pixels%$(gettext 'pixels')%g" /tmp/report-video_
}
export -f func

sed -i "s%millimeters%$(gettext 'millimeters')%g" /tmp/report-video
sed -i "s%planes%$(gettext 'planes')%g" /tmp/report-video
sed -i "s%pixels%$(gettext 'pixels')%g" /tmp/report-video

with:
Code:
func () {
sed -i "s%<b>%%g";"s%</b>%%g";"s%millimeters%$(gettext 'millimeters')%g";"s%planes%$(gettext 'planes')%g";"s%pixels%$(gettext 'pixels')%g" /tmp/report-video_
}
export -f func

sed -i "s%millimeters%$(gettext 'millimeters')%g";"s%planes%$(gettext 'planes')%g";"s%pixels%$(gettext 'pixels')%g" /tmp/report-video
And I got:
Quote:
sed: no input files
/usr/sbin/2P_report-video: line 127: s%planes%niveaux%g: command not found
/usr/sbin/2P_report-video: line 127: s%pixels%pixels%g: command not found
sed: no input files
sh: line 1: s%</b>%%g: No such file or directory
sh: line 2: s%millimeters%millimètres%g: command not found
sh: line 3: s%planes%niveaux%g: command not found
sh: line 4: s%pixels%pixels%g: command not found
EXIT="OK"
Script completed hit RETURN to close window.

Shocked Embarassed

Cordialement.
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Sat 16 Mar 2013, 11:42    Post subject:  

Argolance wrote:
...Following the code lines above, I replaced:..

Pas "tres" exactement ... Wink
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2238

PostPosted: Sat 16 Mar 2013, 11:44    Post subject:  

The syntax is like this:
Code:
sed -i -e '....' -e '...' filename

or:
Code:
sed -i -e '....' \
-e '...' \
-e '...' filename
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Sat 16 Mar 2013, 11:54    Post subject:  

or:
Quote:
sed -i -e "....;...;..." filename
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1825
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 16 Mar 2013, 13:01    Post subject:  

Quote:
Pas "tres" exactement ...
Pas exactement du tout! Sorry!
Code:
func () {
sed -i "s%<b>%%g;s%</b>%%g;s%millimeters%$(gettext 'millimeters')%g;s%planes%$(gettext 'planes')%g;s%pixels%$(gettext 'pixels')%g" /tmp/report-video_
}
export -f func

sed -i "s%millimeters%$(gettext 'millimeters')%g;s%planes%$(gettext 'planes')%g;s%pixels%$(gettext 'pixels')%g" /tmp/report-video

As we are used to say in French: "I had no eyes in front of holes"
This is very much better this way! Very Happy
Thank you!

Cordialement.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 2 [22 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0638s ][ Queries: 13 (0.0042s) ][ GZIP on ]