GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Bash Scripters (https://gfy.com/showthread.php?t=1061688)

fris 03-19-2012 12:40 PM

Bash Scripters
 
Anyone think of a shorter way of doing this?

it converts a directory of ttf and otf fonts to cufon (also removes capitals and spaces)

Code:

#!/bin/bash

for f in *.otf *.ttf; do
php convert.php "$f" -u "U+??" > $(echo ${f%.*}.font.js | tr ' [A-Z]-' '_[a-z]_' | tr -s _);
done


fris 03-19-2012 12:53 PM

or i could use shopt

Code:

#!/bin/bash

shopt -s extglob;
for f in *.otf *.ttf; do
out=${f%.*}.font.js out=${out,,} out=${out//+([[:blank:]-])/_}; php convert.php "$f" -u 'U+??' > "$out";
done


KillerK 03-19-2012 04:37 PM

What's wrong with the way you are doing it?

fris 03-22-2012 07:07 AM

Quote:

Originally Posted by KillerK (Post 18833384)
What's wrong with the way you are doing it?

nothing, did a test shopt runs faster then the latter.


All times are GMT -7. The time now is 10:32 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc