Zenity: get selected filename without its path
Clash Royale CLAN TAG#URR8PPP
I need zenity
to put a selected filename into a variable without its path.
What I have now is
file_to_copy="$(zenity --file-selection --title='Select a File')"
echo $file_to_copy
then prints
/home/blades/Scripts/openwrt-vpn-renew/ze.sh
I wanted to just print ze.sh
.
command-line zenity
|
show 1 more comment
I need zenity
to put a selected filename into a variable without its path.
What I have now is
file_to_copy="$(zenity --file-selection --title='Select a File')"
echo $file_to_copy
then prints
/home/blades/Scripts/openwrt-vpn-renew/ze.sh
I wanted to just print ze.sh
.
command-line zenity
3
Do you really needzenity
to provide this natively? can you not just use"$file_to_copy##*/"
(or use thebasename
command)?
– steeldriver
Dec 16 at 11:29
steeldriver yes that's it. "$file_to_copy##*/" Thanx so much.
– blades
Dec 16 at 11:37
1
@steeldriver I wanted to close this as a duplicate but it is over on Stack Overflow: stackoverflow.com/questions/2664740/…. Could you post an answer here that can be accepted? (Ping me and I'll up-vote :))
– WinEunuuchs2Unix
Dec 16 at 15:31
@WinEunuuchs2Unix done - please see below
– steeldriver
Dec 16 at 16:06
1
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
Dec 16 at 17:04
|
show 1 more comment
I need zenity
to put a selected filename into a variable without its path.
What I have now is
file_to_copy="$(zenity --file-selection --title='Select a File')"
echo $file_to_copy
then prints
/home/blades/Scripts/openwrt-vpn-renew/ze.sh
I wanted to just print ze.sh
.
command-line zenity
I need zenity
to put a selected filename into a variable without its path.
What I have now is
file_to_copy="$(zenity --file-selection --title='Select a File')"
echo $file_to_copy
then prints
/home/blades/Scripts/openwrt-vpn-renew/ze.sh
I wanted to just print ze.sh
.
command-line zenity
command-line zenity
edited Dec 16 at 18:15
Zanna
50k13131238
50k13131238
asked Dec 16 at 11:23
blades
306
306
3
Do you really needzenity
to provide this natively? can you not just use"$file_to_copy##*/"
(or use thebasename
command)?
– steeldriver
Dec 16 at 11:29
steeldriver yes that's it. "$file_to_copy##*/" Thanx so much.
– blades
Dec 16 at 11:37
1
@steeldriver I wanted to close this as a duplicate but it is over on Stack Overflow: stackoverflow.com/questions/2664740/…. Could you post an answer here that can be accepted? (Ping me and I'll up-vote :))
– WinEunuuchs2Unix
Dec 16 at 15:31
@WinEunuuchs2Unix done - please see below
– steeldriver
Dec 16 at 16:06
1
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
Dec 16 at 17:04
|
show 1 more comment
3
Do you really needzenity
to provide this natively? can you not just use"$file_to_copy##*/"
(or use thebasename
command)?
– steeldriver
Dec 16 at 11:29
steeldriver yes that's it. "$file_to_copy##*/" Thanx so much.
– blades
Dec 16 at 11:37
1
@steeldriver I wanted to close this as a duplicate but it is over on Stack Overflow: stackoverflow.com/questions/2664740/…. Could you post an answer here that can be accepted? (Ping me and I'll up-vote :))
– WinEunuuchs2Unix
Dec 16 at 15:31
@WinEunuuchs2Unix done - please see below
– steeldriver
Dec 16 at 16:06
1
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
Dec 16 at 17:04
3
3
Do you really need
zenity
to provide this natively? can you not just use "$file_to_copy##*/"
(or use the basename
command)?– steeldriver
Dec 16 at 11:29
Do you really need
zenity
to provide this natively? can you not just use "$file_to_copy##*/"
(or use the basename
command)?– steeldriver
Dec 16 at 11:29
steeldriver yes that's it. "$file_to_copy##*/" Thanx so much.
– blades
Dec 16 at 11:37
steeldriver yes that's it. "$file_to_copy##*/" Thanx so much.
– blades
Dec 16 at 11:37
1
1
@steeldriver I wanted to close this as a duplicate but it is over on Stack Overflow: stackoverflow.com/questions/2664740/…. Could you post an answer here that can be accepted? (Ping me and I'll up-vote :))
– WinEunuuchs2Unix
Dec 16 at 15:31
@steeldriver I wanted to close this as a duplicate but it is over on Stack Overflow: stackoverflow.com/questions/2664740/…. Could you post an answer here that can be accepted? (Ping me and I'll up-vote :))
– WinEunuuchs2Unix
Dec 16 at 15:31
@WinEunuuchs2Unix done - please see below
– steeldriver
Dec 16 at 16:06
@WinEunuuchs2Unix done - please see below
– steeldriver
Dec 16 at 16:06
1
1
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
Dec 16 at 17:04
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
Dec 16 at 17:04
|
show 1 more comment
1 Answer
1
active
oldest
votes
If you don't absolutely need zenity
to provide this functionality for you, then you can easily do it in the shell, either using parameter expansion
file_to_copy=$file_to_copy##*/
where ##*/
refers to the longest leading string matching */
, or using the basename
utility
file_to_copy=$(basename "$file_to_copy")
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102290%2fzenity-get-selected-filename-without-its-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you don't absolutely need zenity
to provide this functionality for you, then you can easily do it in the shell, either using parameter expansion
file_to_copy=$file_to_copy##*/
where ##*/
refers to the longest leading string matching */
, or using the basename
utility
file_to_copy=$(basename "$file_to_copy")
add a comment |
If you don't absolutely need zenity
to provide this functionality for you, then you can easily do it in the shell, either using parameter expansion
file_to_copy=$file_to_copy##*/
where ##*/
refers to the longest leading string matching */
, or using the basename
utility
file_to_copy=$(basename "$file_to_copy")
add a comment |
If you don't absolutely need zenity
to provide this functionality for you, then you can easily do it in the shell, either using parameter expansion
file_to_copy=$file_to_copy##*/
where ##*/
refers to the longest leading string matching */
, or using the basename
utility
file_to_copy=$(basename "$file_to_copy")
If you don't absolutely need zenity
to provide this functionality for you, then you can easily do it in the shell, either using parameter expansion
file_to_copy=$file_to_copy##*/
where ##*/
refers to the longest leading string matching */
, or using the basename
utility
file_to_copy=$(basename "$file_to_copy")
answered Dec 16 at 16:06
steeldriver
65.6k11104176
65.6k11104176
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102290%2fzenity-get-selected-filename-without-its-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Do you really need
zenity
to provide this natively? can you not just use"$file_to_copy##*/"
(or use thebasename
command)?– steeldriver
Dec 16 at 11:29
steeldriver yes that's it. "$file_to_copy##*/" Thanx so much.
– blades
Dec 16 at 11:37
1
@steeldriver I wanted to close this as a duplicate but it is over on Stack Overflow: stackoverflow.com/questions/2664740/…. Could you post an answer here that can be accepted? (Ping me and I'll up-vote :))
– WinEunuuchs2Unix
Dec 16 at 15:31
@WinEunuuchs2Unix done - please see below
– steeldriver
Dec 16 at 16:06
1
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
Dec 16 at 17:04