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 Thu 27 Nov 2014, 09:27
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 Posts_count   Goto page: Previous 1, 2
Author Message
don570


Joined: 10 Mar 2010
Posts: 3380
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: 1847
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_website 
Argolance


Joined: 06 Jan 2008
Posts: 1847
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_website 
L18L

Joined: 19 Jun 2010
Posts: 2579
Location: www.eussenheim.de/

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: 2279

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: 2579
Location: www.eussenheim.de/

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: 1847
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_website 
Display_posts:   Sort by:   
Page 2 of 2 Posts_count   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:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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