Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-30-2009, 09:30 AM   #1
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Rep: Reputation: 37
[BASH] variable assignment help

Hi guys,

I have this piece of code here:


zip -rm ${folder}.zip $folder
mv -t ../done ${folder}.zip
What happens is that I will be doing that over and over again for a few days so I decided to create a little script for it but I dont know if you could guess it... it creates a small problem...

when I do zipit M[TAB] to auto complete the auto complete adds a "/" at the end of the folder name, and what the script does is that it creates a file named ".zip" with the contents inside...

The question is, how can i assign folder=$1 but deleting the "/"... or perhaps a more correct variable expansion in ${folder}.zip would help? but im not sure about it since im little new in bash scripting.

Any other suggestions are appreciated.
Old 08-30-2009, 09:34 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Look in the bash info manual for variable expansion.

Old 08-30-2009, 10:28 AM   #3
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Original Poster
Rep: Reputation: 37
Thanks, I will read it today.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
about immediate and deferred variable assignment in GNU make George2 Programming 1 07-22-2011 05:55 PM
How to get variable from text file into Bash variable mcdef Linux - Software 2 06-10-2009 01:15 PM
trivial: bash, local variable assignment agrestic Linux - Newbie 3 01-27-2009 11:30 AM
Java String variable re-assignment Cyhaxor Programming 9 11-24-2007 03:35 PM
Bash assignment - using a grep inside an if statement lowpro2k3 Programming 4 03-25-2005 05:24 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration