basename extra operand error
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
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’
bash shell
add a comment |
up vote
-1
down vote
favorite
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’
bash shell
1
Quote your variables - see Why does my shell script choke on whitespace or other special characters?
– steeldriver
2 hours ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
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’
bash shell
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’
bash shell
bash shell
edited 2 hours ago
Rui F Ribeiro
38k1475123
38k1475123
asked 2 hours ago
ksa_coder
1084
1084
1
Quote your variables - see Why does my shell script choke on whitespace or other special characters?
– steeldriver
2 hours ago
add a comment |
1
Quote your variables - see Why does my shell script choke on whitespace or other special characters?
– steeldriver
2 hours ago
1
1
Quote your variables - see Why does my shell script choke on whitespace or other special characters?
– steeldriver
2 hours ago
Quote your variables - see Why does my shell script choke on whitespace or other special characters?
– steeldriver
2 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480890%2fbasename-extra-operand-error%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Quote your variables - see Why does my shell script choke on whitespace or other special characters?
– steeldriver
2 hours ago