Shell tricks (was: [TxMt] Xetex)

Robert Ullrey robert_ullrey at mac.com
Tue Apr 12 14:05:59 UTC 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Allan, I'm going to flag this message to refer to again and 
again. Especially the stdin <<< which i keep forgetting about.

Please feel free to keep the tips coming ;)

Robert


On Apr 12, 2005, at 7:00 AM, Allan Odgaard wrote:

> On Apr 11, 2005, at 17:34, Alain Matthes wrote:
>
>> echo $TM_FILEPATH | perl -e 'while(<>){s/\.tex$/.pdf/;print;}' | xargs
>
> I generally avoid commenting on code unless I'm asked, but here's a 
> few tips which I think will be useful in a lot of TM-related shell 
> scripts, don't take it personal that this was triggered by your 
> script! :)
>
> The shell is capable of doing replacements in variables. There's a few 
> different forms, for this one, one can do: 
> ${variable%suffix_to_remove}, e.g.:
>
>    ${TM_FILEPATH%.tex}.pdf
>
> Another form is (for single replacement): ${variable/search/replace} 
> and to replace all instances it's: ${variable//search/replace}.
>
> Another neat thing is that we can set stdin for a command to a string 
> using <<<, for example:
>
>    perl <<<$TM_FILEPATH -pe 's/\.tex$/.pdf/' | xargs
>
> Kind regards Allan
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1

iQA/AwUBQlvV02O1AQX/YDblEQIn5QCg6EoOvzLy+adV9B8NNrHj7znLi+8An0Vs
5BiaD70OtL3jJntDd0gcqr29
=/DXc
-----END PGP SIGNATURE-----




More information about the textmate mailing list