Results 1 to 3 of 3
Hi all. I have a fairly simple question, but I can't find the answer anywhere on the internet. All I'm trying to do is get my bash script to rename ...
- 03-23-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 2
Output a variable to command
Hi all. I have a fairly simple question, but I can't find the answer anywhere on the internet. All I'm trying to do is get my bash script to rename some files.
The command I want the script to run is of the form
rename 's/4s/2p/' *
but in place of 4s I want my variable. If I just try something like this
var=4s
rename 's/${var}/2p/' *
I get an error "Global symbol "$var" requires explicit package name at (eval 1) line 1."
I've tried about a dozen different things now. Obviously the problem is the use of the quotation marks but I just can't work it out. I would be very grateful if someone can show me the correct syntax.
Thankyou
- 03-23-2009 #2
First, try double quotation marks. (")
If this doesn't work, use xargs.Debian GNU/Linux -- You know you want it.
- 03-23-2009 #3Just Joined!
- Join Date
- Mar 2009
- Posts
- 2
Fantastic, works perfectly, thankyou.
Now I feel incredibly silly for not doing that initially, instead of the incredibly long and convoluted expressions I've been trying for the last half hour.


Reply With Quote