Unix/Linux Go Back    



separating filename and extension

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member radoulov Regarding:
separating filename and extension.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 04-06-2007   -   Original Discussion by lucaspewkas
radoulov's Unix or Linux Image
radoulov radoulov is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 9 January 2017, 4:40 AM EST
Location: Варна, България / Milano, Italia
Posts: 5,690
Thanks: 184
Thanked 630 Times in 587 Posts

Code:
for f in test_suite/*.args;do 
	fn="${f%.*}" 
	printf "filename without path and extension: %s, extension only: %s\n" "${fn##*/}" "${f##*.}"  
done

With bash you can do something like this (if I understand correctly the requirement):

Code:
set test_suite/*.args
set "${@##*/}"
printf "%s\n" "${@%.*}">file.out


Last edited by radoulov; 04-06-2007 at 08:40 AM..