Register
It is currently Sat Oct 25, 2014 6:39 am

String manipulation with special characters


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon May 09, 2011 5:56 pm   

Joined: Mon May 09, 2011 5:46 pm
Posts: 2
String manipulation with string contaning backslash:

I want to extract the width tag from the LaTeX line:
\subfloat[]{\label{fig:PCNC-BD-Dbieni}\includegraphics[width=0.09\textwidth]{figuras/BDID/PCNC/bien_selec/tornilloGota_0014.png}}
to this:
0.09\textwidth

Using this:

temp1=${line#*[width=}
widthStr=${temp1%]*}
echo -E WIDTHStr: $widthStr
widthStr2number $widthStr 10 100
echo width: $width

I get:

0.09textwidth


So my problem is that the first line of code has ate the backslash. And any tip or hint over the Internet appears to be available for help in this issue.

Note. the original line is extracted from a LaTeX tex file using:
grep includegraphics $TEXFILE > $tempFile

Regards.


Top
 Profile  
 PostPosted: Mon May 09, 2011 6:06 pm   

Joined: Mon May 09, 2011 5:46 pm
Posts: 2
Stupid, the solution was adding option -r to the read command o_O
So the backslash is not interpeted

while read -r line
do
...
done < $tempFile


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 3 guests


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 post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP