Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Basename a file with spaces

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-02-2008
linge linge is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 6 August 2010, 10:40 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Basename a file with spaces

Hi,

I'm trying to get the filename from a full path, but the filename contain spaces. So basename tries to remove the "suffix" which is part of the filename...

Ex.
#!/bin/ksh
INPUT=/full/path/file with space.mp3
FILE=$(basename $INPUT)


This will return a basename exception trying to remove the suffix "with space.mp3"

Any solution?

Thanks
Sponsored Links
    #2  
Old Unix and Linux 12-02-2008
demwz demwz is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 27 September 2011, 4:18 AM EDT
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
FILE=$(basename "$INPUT")
Sponsored Links
    #3  
Old Unix and Linux 12-02-2008
linge linge is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 6 August 2010, 10:40 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks!
Worked first try. Maybe should have been in the Dummies section...
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk and basename kaboink UNIX for Dummies Questions & Answers 10 11-28-2011 06:48 AM
basename venkatesht UNIX for Dummies Questions & Answers 2 03-31-2010 06:27 AM
basename + file with space jagnikam Shell Programming and Scripting 5 02-10-2010 10:21 AM
Removing blank spaces, tab spaces from file NARESH1302 Shell Programming and Scripting 3 08-07-2009 11:18 AM
basename $0 kripssmart Shell Programming and Scripting 4 05-12-2009 05:13 AM



All times are GMT -4. The time now is 06:19 PM.