BashScripts.org
http://bashscripts.org/forum/

Strip a path with spaces
http://bashscripts.org/forum/viewtopic.php?f=16&t=1451
Page 1 of 1

Author:  djtmc [ Thu Sep 08, 2011 4:57 pm ]
Post subject:  Strip a path with spaces

Well, the title says it all, really. I want to strip a path to leave me with just the filename at the end. Problem is, both path and file may - or may not - have spaces in them, which basename doesn't like and I can't work out how to do this. Googling doesn't help, either (Google and I have an arrangement - Google promises to only provide me with 100% relevant results provided I, in turn, promise to never actually ask for anything).

How do I do this, please?

Many thanks,

David Shaw

Author:  djtmc [ Thu Sep 08, 2011 5:03 pm ]
Post subject:  Re: Strip a path with spaces

OK, sorry to have bothered you. My bad - I got my quoting wrong. All fixed and working now.

David Shaw

Author:  jeo [ Fri Sep 09, 2011 2:41 pm ]
Post subject:  Re: Strip a path with spaces

No problem! Working with spaces can be a pain... Quotes are important! There are other ways of dealing with spaces as well, such as temporarily changing the IFS (Internal Field Separator) of the shell for the duration of your script.

Author:  jsz [ Tue Sep 20, 2011 12:42 pm ]
Post subject:  Re: Strip a path with spaces

You really don't need basename(1).
See the first function of my post in here.

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com