Register
It is currently Mon Oct 20, 2014 2:10 am

How to cut " " from end of variable


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sun Apr 03, 2011 9:27 am   

Joined: Sun Apr 03, 2011 9:18 am
Posts: 1
I have a variable zamik, which is concatenated from a and b
So it looks something like:
Code:
a="|   " 
b="    ".
"|          |                  |                         ".

I'd like to cut last empty spaces, so it would look like:
Code:
"|          |                  |".


I tried many things, like:
zamik=${zamik#*|}
zamik=${zamik%|*}
zamik=${zamik%%\x20}
zamik=${zamik%"|"}

but none works...


Top
 Profile  
 PostPosted: Tue Apr 05, 2011 2:22 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Turn extglob on and use
Code:
zamik="${zamik%%+( )}"


Top
 Profile  
 PostPosted: Tue May 03, 2011 11:32 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Bash Parameter Expansion
http://bashcurescancer.com/10-steps-to- ... ripts.html

I love that concise explanation... I believe that is the original author of the document, at least it's the oldest version I could find, it's been copied all over the net of course (because it's useful). You might look at that link :) It help(ed/s) me alot. :D


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 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