Creating a bash alias that ends in single quotation
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a command line string:
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
which outputs file names in the current folder, in a single line, surrounded by quotations.
I attempted to add this to my .bash_profile as an alias, however I think the single quotes are causing an issue and I can't get it to work.
I tried this with no luck:
alias='ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' ''
How would one go about creating an alias for the above?
Thanks in advance to anyone who can help with this noob question and I appreciate your time :)
Cheers,
Stephen.
bash command-line-interface alias
add a comment |
I have a command line string:
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
which outputs file names in the current folder, in a single line, surrounded by quotations.
I attempted to add this to my .bash_profile as an alias, however I think the single quotes are causing an issue and I can't get it to work.
I tried this with no luck:
alias='ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' ''
How would one go about creating an alias for the above?
Thanks in advance to anyone who can help with this noob question and I appreciate your time :)
Cheers,
Stephen.
bash command-line-interface alias
add a comment |
I have a command line string:
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
which outputs file names in the current folder, in a single line, surrounded by quotations.
I attempted to add this to my .bash_profile as an alias, however I think the single quotes are causing an issue and I can't get it to work.
I tried this with no luck:
alias='ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' ''
How would one go about creating an alias for the above?
Thanks in advance to anyone who can help with this noob question and I appreciate your time :)
Cheers,
Stephen.
bash command-line-interface alias
I have a command line string:
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
which outputs file names in the current folder, in a single line, surrounded by quotations.
I attempted to add this to my .bash_profile as an alias, however I think the single quotes are causing an issue and I can't get it to work.
I tried this with no luck:
alias='ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' ''
How would one go about creating an alias for the above?
Thanks in advance to anyone who can help with this noob question and I appreciate your time :)
Cheers,
Stephen.
bash command-line-interface alias
bash command-line-interface alias
edited Nov 22 '18 at 13:21
Stephen J Pereira
asked Nov 22 '18 at 13:17
Stephen J PereiraStephen J Pereira
62
62
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
work here with using "
alias X="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
1
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
add a comment |
Enquote the whole command in double quotes and escape the double quotes inside the command with a backslash:
alias a="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
or use a function
a() {
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
}
By the way: Parsing ls is a bad practice. It would be safer and easier to use globs and printf:
printf '"%s" ' *
or, if you want to properly quote for using the arguments inside eval or something similar
printf '%q ' *
add a comment |
The alias should enclose the command line into ' AND each already existing ' should be escaped with '''
Give a try to this:
alias lsquoted='ls | sed -e '''s/^/"/g''' -e '''s/$/"/g''' | tr '''n''' ''' ''''
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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%2fstackoverflow.com%2fquestions%2f53431883%2fcreating-a-bash-alias-that-ends-in-single-quotation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
work here with using "
alias X="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
1
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
add a comment |
work here with using "
alias X="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
1
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
add a comment |
work here with using "
alias X="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
work here with using "
alias X="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
answered Nov 22 '18 at 13:21
Incrivel Monstro VerdeIncrivel Monstro Verde
43316
43316
1
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
add a comment |
1
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
1
1
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
Thank you so much :) that worked perfectly!
– Stephen J Pereira
Nov 22 '18 at 13:23
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
@StephenJPereira If you problem was resolved, you should accept an answer to close the question.
– Socowi
Nov 23 '18 at 16:57
add a comment |
Enquote the whole command in double quotes and escape the double quotes inside the command with a backslash:
alias a="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
or use a function
a() {
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
}
By the way: Parsing ls is a bad practice. It would be safer and easier to use globs and printf:
printf '"%s" ' *
or, if you want to properly quote for using the arguments inside eval or something similar
printf '%q ' *
add a comment |
Enquote the whole command in double quotes and escape the double quotes inside the command with a backslash:
alias a="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
or use a function
a() {
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
}
By the way: Parsing ls is a bad practice. It would be safer and easier to use globs and printf:
printf '"%s" ' *
or, if you want to properly quote for using the arguments inside eval or something similar
printf '%q ' *
add a comment |
Enquote the whole command in double quotes and escape the double quotes inside the command with a backslash:
alias a="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
or use a function
a() {
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
}
By the way: Parsing ls is a bad practice. It would be safer and easier to use globs and printf:
printf '"%s" ' *
or, if you want to properly quote for using the arguments inside eval or something similar
printf '%q ' *
Enquote the whole command in double quotes and escape the double quotes inside the command with a backslash:
alias a="ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '"
or use a function
a() {
ls | sed -e 's/^/"/g' -e 's/$/"/g' | tr 'n' ' '
}
By the way: Parsing ls is a bad practice. It would be safer and easier to use globs and printf:
printf '"%s" ' *
or, if you want to properly quote for using the arguments inside eval or something similar
printf '%q ' *
answered Nov 22 '18 at 13:21
SocowiSocowi
7,93921428
7,93921428
add a comment |
add a comment |
The alias should enclose the command line into ' AND each already existing ' should be escaped with '''
Give a try to this:
alias lsquoted='ls | sed -e '''s/^/"/g''' -e '''s/$/"/g''' | tr '''n''' ''' ''''
add a comment |
The alias should enclose the command line into ' AND each already existing ' should be escaped with '''
Give a try to this:
alias lsquoted='ls | sed -e '''s/^/"/g''' -e '''s/$/"/g''' | tr '''n''' ''' ''''
add a comment |
The alias should enclose the command line into ' AND each already existing ' should be escaped with '''
Give a try to this:
alias lsquoted='ls | sed -e '''s/^/"/g''' -e '''s/$/"/g''' | tr '''n''' ''' ''''
The alias should enclose the command line into ' AND each already existing ' should be escaped with '''
Give a try to this:
alias lsquoted='ls | sed -e '''s/^/"/g''' -e '''s/$/"/g''' | tr '''n''' ''' ''''
answered Nov 22 '18 at 13:23
Jay jargotJay jargot
1,9621511
1,9621511
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f53431883%2fcreating-a-bash-alias-that-ends-in-single-quotation%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