[NTLUG:Discuss] bash question

Wrenn, Bobby J. Bobby.Wrenn at banctec.com
Fri Sep 14 13:46:11 CDT 2001


If anyone is interested Richard's correction worked. While that in itself
may not be surprising, that I understood most of this is startling!

Thanks again to all who helped
Bobby

-----Original Message-----
From: Richard Cobbe [mailto:cobbe at airmail.net]
Sent: Friday, September 14, 2001 11:54 AM
To: discuss at ntlug.org
Subject: RE: [NTLUG:Discuss] bash question


Lo, on Thursday, September 13, Wrenn, Bobby J. did write:

> So, I'll ask again. 

(Sorry, I get this list in digest form; both your questions just arrived at
once.)

> 
> Will the converse work? If I want to put the spaces back in, would:
> 
>     mv "$file" ${file/-// }
> 
> be the correct expression?

Almost---
    mv "$file" "${file//-/ }"
(...assuming, of course, that you don't have any extraneous hyphens in your
filenames.)  Note the position of the double slash and the quotes.

The double slash goes between the variable name and the pattern to be
replaced; it means `replace all instances' instead of `just replace the
first'.  In your attempt, the replacement string would, I think, be `/ ',
which won't work---the slash will get interpreted as a directory separator,
causing all kinds of error messages.

Check out the `Parameter Expansion' section of the bash manpage for the
full story.

Richard
_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss



More information about the Discuss mailing list