Jump to content

Cygwin Bash \r


The Little Guy

Recommended Posts

I am running a bash script in Cygwin and running this:

 

height=`identify -format "%h" $image`

 

it returns the height of the image such as:

768

 

but then when I try to add 80 to that number I can't because there is a \r at the end of it.

 

how can I add the two numbers?

 

Full Code:

cd "C:\phpDocs\images"

image='Tulips.jpg'

width=`identify -format "%w" $image`
height=`identify -format "%h" $image`

((height+=80))

convert -size $widthx$height canvas:black new.jpg
composite -compose atop -gravity south -tile logo.png new.jpg new.jpg
composite -compose atop -gravity north Tulips.jpg new.jpg new.jpg

 

Error:

")syntax error: invalid arithmetic operator (error token is "

Link to comment
Share on other sites

Try this:

 

height=${height%%$'\x0D'}
((height+=80))

 

 

Sweet, that works!

 

 

one more thing, how can I place a variable in a command?

 

sub section of the command:

$widthx$hight

 

variables: $width, $height

 

should display like so:

1024x848

 

I cant do that, because it seems to think that $widthx is the variable when it is just $width

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.