Sample Header Ad - 728x90

basename extra operand error

3 votes
1 answer
19939 views
I have a script that will try to extract the file's base name and then I do additional work with it. Only when using this script with a file with this naming convention (including spaces and characters - not really sure what's triggering the error), do I get the basename extra operand error. The file name: JERASH - XZ 837367432.pdf Here the script once executed generates error: filetimestamp=$(date "+%F-%T") timenow=$(date -u) for file in files/input/* do printf "Break 1 \n" #filename no extension: filenamenopath=$(basename $file) filenamenoext=${filenamenopath%.pdf} printf "Break 2 \n" #check if file is pdf printf "File Name with No Path:" $filenamenopath printf "Break 3 \n" And here is the error: > Break 1 basename: extra operand ‘XZ’
Asked by ksa_coder (153 rep)
Nov 10, 2018, 03:44 AM
Last activity: Oct 7, 2019, 05:31 AM