Why did this command put a whitespace at the beginning?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have this code in a shell script:
sort input | uniq -c | sort -nr > output
The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash
command-line bash uniq
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
I have this code in a shell script:
sort input | uniq -c | sort -nr > output
The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash
command-line bash uniq
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have this code in a shell script:
sort input | uniq -c | sort -nr > output
The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash
command-line bash uniq
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have this code in a shell script:
sort input | uniq -c | sort -nr > output
The input file had no preceding white spaces, but the output does. How do I fix this? This is in bash
command-line bash uniq
command-line bash uniq
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 11 mins ago


wjandrea
7,45142257
7,45142257
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 52 mins ago


Jeremy Wik
61
61
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Jeremy Wik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
The default behaviour of uniq is to right-justify the frequency in a
line 7 spaces wide, then separate the frequency from the item with a
single space.
Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c
Remove the leading spaces with sed :
$ sort input | uniq -c | sort -nr | sed 's/^s*//' > output
add a comment |Â
up vote
1
down vote
uniq -c
adds leading whitespace. E.g.
$ echo test
test
$ echo test | uniq -c
1 test
You could add a command at the end of the pipeline to remove it. E.g.
$ echo test | uniq -c | sed 's/^s*//'
1 test
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The default behaviour of uniq is to right-justify the frequency in a
line 7 spaces wide, then separate the frequency from the item with a
single space.
Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c
Remove the leading spaces with sed :
$ sort input | uniq -c | sort -nr | sed 's/^s*//' > output
add a comment |Â
up vote
2
down vote
The default behaviour of uniq is to right-justify the frequency in a
line 7 spaces wide, then separate the frequency from the item with a
single space.
Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c
Remove the leading spaces with sed :
$ sort input | uniq -c | sort -nr | sed 's/^s*//' > output
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The default behaviour of uniq is to right-justify the frequency in a
line 7 spaces wide, then separate the frequency from the item with a
single space.
Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c
Remove the leading spaces with sed :
$ sort input | uniq -c | sort -nr | sed 's/^s*//' > output
The default behaviour of uniq is to right-justify the frequency in a
line 7 spaces wide, then separate the frequency from the item with a
single space.
Source : https://www.thelinuxrain.com/articles/tweaking-uniq-c
Remove the leading spaces with sed :
$ sort input | uniq -c | sort -nr | sed 's/^s*//' > output
edited 20 mins ago


wjandrea
7,45142257
7,45142257
answered 25 mins ago
Gounou
935
935
add a comment |Â
add a comment |Â
up vote
1
down vote
uniq -c
adds leading whitespace. E.g.
$ echo test
test
$ echo test | uniq -c
1 test
You could add a command at the end of the pipeline to remove it. E.g.
$ echo test | uniq -c | sed 's/^s*//'
1 test
add a comment |Â
up vote
1
down vote
uniq -c
adds leading whitespace. E.g.
$ echo test
test
$ echo test | uniq -c
1 test
You could add a command at the end of the pipeline to remove it. E.g.
$ echo test | uniq -c | sed 's/^s*//'
1 test
add a comment |Â
up vote
1
down vote
up vote
1
down vote
uniq -c
adds leading whitespace. E.g.
$ echo test
test
$ echo test | uniq -c
1 test
You could add a command at the end of the pipeline to remove it. E.g.
$ echo test | uniq -c | sed 's/^s*//'
1 test
uniq -c
adds leading whitespace. E.g.
$ echo test
test
$ echo test | uniq -c
1 test
You could add a command at the end of the pipeline to remove it. E.g.
$ echo test | uniq -c | sed 's/^s*//'
1 test
answered 25 mins ago


wjandrea
7,45142257
7,45142257
add a comment |Â
add a comment |Â
Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.
Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.
Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.
Jeremy Wik is a new contributor. Be nice, and check out our Code of Conduct.
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%2faskubuntu.com%2fquestions%2f1087885%2fwhy-did-this-command-put-a-whitespace-at-the-beginning%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