Coreutils (or otherwise) `ls`: don't append symbol indicating type when piped

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?
the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.
command-line ls coreutils
add a comment |Â
up vote
0
down vote
favorite
Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?
the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.
command-line ls coreutils
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?
the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.
command-line ls coreutils
Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?
the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.
command-line ls coreutils
asked Feb 27 at 19:35
Ivan G.
334
334
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.
function ls
if [ -t 1 ]
then
command ls -F "$@"
else
command ls "$@"
fi
Adjust the other default options as you like.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.
function ls
if [ -t 1 ]
then
command ls -F "$@"
else
command ls "$@"
fi
Adjust the other default options as you like.
add a comment |Â
up vote
1
down vote
accepted
Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.
function ls
if [ -t 1 ]
then
command ls -F "$@"
else
command ls "$@"
fi
Adjust the other default options as you like.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.
function ls
if [ -t 1 ]
then
command ls -F "$@"
else
command ls "$@"
fi
Adjust the other default options as you like.
Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.
function ls
if [ -t 1 ]
then
command ls -F "$@"
else
command ls "$@"
fi
Adjust the other default options as you like.
answered Feb 27 at 20:11
Jeff Schaller
31.2k846105
31.2k846105
add a comment |Â
add a comment |Â
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%2f427007%2fcoreutils-or-otherwise-ls-dont-append-symbol-indicating-type-when-piped%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