Zenity: get selected filename without its path
up vote
2
down vote
favorite
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
add a comment |
up vote
2
down vote
favorite
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
7 hours ago
steeldriver yes that's it. "${file_to_copy##*/}" Thanx so much.
– blades
7 hours ago
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
3 hours ago
@WinEunuuchs2Unix done - please see below
– steeldriver
3 hours ago
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
2 hours ago
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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 1 hour ago
Zanna
49.4k13127236
49.4k13127236
asked 7 hours ago
blades
256
256
3
Do you really needzenity
to provide this natively? can you not just use"${file_to_copy##*/}"
(or use thebasename
command)?
– steeldriver
7 hours ago
steeldriver yes that's it. "${file_to_copy##*/}" Thanx so much.
– blades
7 hours ago
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
3 hours ago
@WinEunuuchs2Unix done - please see below
– steeldriver
3 hours ago
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
2 hours ago
add a comment |
3
Do you really needzenity
to provide this natively? can you not just use"${file_to_copy##*/}"
(or use thebasename
command)?
– steeldriver
7 hours ago
steeldriver yes that's it. "${file_to_copy##*/}" Thanx so much.
– blades
7 hours ago
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
3 hours ago
@WinEunuuchs2Unix done - please see below
– steeldriver
3 hours ago
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
2 hours ago
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
7 hours ago
Do you really need
zenity
to provide this natively? can you not just use "${file_to_copy##*/}"
(or use the basename
command)?– steeldriver
7 hours ago
steeldriver yes that's it. "${file_to_copy##*/}" Thanx so much.
– blades
7 hours ago
steeldriver yes that's it. "${file_to_copy##*/}" Thanx so much.
– blades
7 hours ago
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
3 hours ago
@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
3 hours ago
@WinEunuuchs2Unix done - please see below
– steeldriver
3 hours ago
@WinEunuuchs2Unix done - please see below
– steeldriver
3 hours ago
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
2 hours ago
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
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',
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
up vote
5
down vote
accepted
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 |
up vote
5
down vote
accepted
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 |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
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 3 hours ago
steeldriver
65.3k11104176
65.3k11104176
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
7 hours ago
steeldriver yes that's it. "${file_to_copy##*/}" Thanx so much.
– blades
7 hours ago
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
3 hours ago
@WinEunuuchs2Unix done - please see below
– steeldriver
3 hours ago
Possible duplicate of Bash: get current working directory name, but not full path
– wjandrea
2 hours ago