Register
It is currently Sat Oct 25, 2014 9:18 am

Strip a path with spaces


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Sep 08, 2011 4:57 pm   

Joined: Thu Sep 08, 2011 4:46 pm
Posts: 2
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


Top
 Profile  
 PostPosted: Thu Sep 08, 2011 5:03 pm   

Joined: Thu Sep 08, 2011 4:46 pm
Posts: 2
OK, sorry to have bothered you. My bad - I got my quoting wrong. All fixed and working now.

David Shaw


Top
 Profile  
 PostPosted: Fri Sep 09, 2011 2:41 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
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.


Top
 Profile YIM  
 PostPosted: Tue Sep 20, 2011 12:42 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
You really don't need basename(1).
See the first function of my post in here.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 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