trim tailing - and add it leading for Numbers in shell
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a CSV file with numbers in double quotes and without double quotes and for some numbers. I have to fix the negative symbols for only numbers: the tailing negative symbol has to be removed and added to the beginning.
Sample Input:
column 1, column 2, column 3, column 4, column 5
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
Sample Output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
text-processing awk csv
add a comment |Â
up vote
1
down vote
favorite
I have a CSV file with numbers in double quotes and without double quotes and for some numbers. I have to fix the negative symbols for only numbers: the tailing negative symbol has to be removed and added to the beginning.
Sample Input:
column 1, column 2, column 3, column 4, column 5
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
Sample Output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
text-processing awk csv
When you say string with quotes, is that double quotes? How are they encoded? By doubling the"
like in most CSV formats? Or with"
as sometimes seen? Can the strings contain newline characters? It would be better to have a real example there.
â Stéphane Chazelas
Dec 6 '17 at 10:40
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a CSV file with numbers in double quotes and without double quotes and for some numbers. I have to fix the negative symbols for only numbers: the tailing negative symbol has to be removed and added to the beginning.
Sample Input:
column 1, column 2, column 3, column 4, column 5
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
Sample Output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
text-processing awk csv
I have a CSV file with numbers in double quotes and without double quotes and for some numbers. I have to fix the negative symbols for only numbers: the tailing negative symbol has to be removed and added to the beginning.
Sample Input:
column 1, column 2, column 3, column 4, column 5
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
Sample Output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
text-processing awk csv
edited Dec 6 '17 at 9:38
fpmurphy1
2,231915
2,231915
asked Dec 5 '17 at 20:33
Kiran
142
142
When you say string with quotes, is that double quotes? How are they encoded? By doubling the"
like in most CSV formats? Or with"
as sometimes seen? Can the strings contain newline characters? It would be better to have a real example there.
â Stéphane Chazelas
Dec 6 '17 at 10:40
add a comment |Â
When you say string with quotes, is that double quotes? How are they encoded? By doubling the"
like in most CSV formats? Or with"
as sometimes seen? Can the strings contain newline characters? It would be better to have a real example there.
â Stéphane Chazelas
Dec 6 '17 at 10:40
When you say string with quotes, is that double quotes? How are they encoded? By doubling the
"
like in most CSV formats? Or with "
as sometimes seen? Can the strings contain newline characters? It would be better to have a real example there.â Stéphane Chazelas
Dec 6 '17 at 10:40
When you say string with quotes, is that double quotes? How are they encoded? By doubling the
"
like in most CSV formats? Or with "
as sometimes seen? Can the strings contain newline characters? It would be better to have a real example there.â Stéphane Chazelas
Dec 6 '17 at 10:40
add a comment |Â
5 Answers
5
active
oldest
votes
up vote
1
down vote
GNU awk
solution:
awk -v FPAT='[^,"]+|"[^"]+"' '
NR==1; NR>1
for (i=1; i<=NF; i++)
if ($i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/)
sub(/-/, "", $i);
sub(/[0-9]/, "-&", $i);
printf "%s%s",$i,(i==NF? ORS:",")
' file.csv
-v FPAT='[^,"]+|"[^"]+"'
- regex pattern defining field value$i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/
- check if a field contains a number with trailing minus sign-
(number could be double-quoted)
The output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran FPAT requires gawk version 4. What is the output ofgawk --version
?
â fpmurphy1
Dec 6 '17 at 0:24
add a comment |Â
up vote
0
down vote
CSV data requires a CSV parser. Ruby has one:
$ cat file.csv
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
$ ruby -rcsv -e '
CSV.foreach(ARGV.shift) do |row|
corrected = row.collect
puts CSV.generate_line(corrected)
end
' file.csv
-12,"-455,365.44",string with quotes-and with a comma in between,"4,432",6787
The CSV generator decided that the "string with quotes" did not need to be quoted because it does not contain a comma.
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
add a comment |Â
up vote
0
down vote
awk solution that does not use gawk
FPAT:
NR==1;
NR > 1
$0 = $0","
while ($0)
( f ~ /^[0-9]+[.]?[0-9]+-$/ )
Output for supplied sample file is:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
add a comment |Â
up vote
0
down vote
With perl
, but not suitable for all sorts of csv
formats, works for given sample
$ perl -ne '@cols=/"[^"]+"|[^,]+/g;
map s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols;
print join ",", @cols' ip.csv
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
@cols=/"[^"]+"|[^,]+/g
save fields in arraymap s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols
change each element of array. The second substitution is used only if first doesn't succeed- change
(.*)
to([d,.]+)
to sort of restrict the matching to digits and,
and.
only. This would still match strings like..,..-
- change
print join ",", @cols
print the changed array with,
as separator
a bit of fun without using temp array
perl -ne 'print join ",", map /^"/ ? s/"(.*)-"$/"-$1"/r : s/(.*)-$/-$1/r /"[^"]+"|[^,]+/g'
add a comment |Â
up vote
0
down vote
With sed
implementations supporting -E
, assuming the double quotes embedded in string fields are encoded as ""
and that those string fields don't contain newline characters:
sed -E '
:1
s/^(("[^"]*"|[^"])*,)?([0-9.]+)-(,|$)/1-34/;
s/^(("[^"]*"|[^"])*,)?"([0-9,.]+)-"(,|$)/1"-3"4/
t1' < file
Depending on the nature of the input, you may want to be stricter in matching the numbers. For instance ([0-9.]+)-
here would match on 12-
but also on ...-
. If that type of input may occur in the input, you could change it to ([0-9]*.?[0-9]+)-
for instance.
add a comment |Â
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
GNU awk
solution:
awk -v FPAT='[^,"]+|"[^"]+"' '
NR==1; NR>1
for (i=1; i<=NF; i++)
if ($i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/)
sub(/-/, "", $i);
sub(/[0-9]/, "-&", $i);
printf "%s%s",$i,(i==NF? ORS:",")
' file.csv
-v FPAT='[^,"]+|"[^"]+"'
- regex pattern defining field value$i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/
- check if a field contains a number with trailing minus sign-
(number could be double-quoted)
The output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran FPAT requires gawk version 4. What is the output ofgawk --version
?
â fpmurphy1
Dec 6 '17 at 0:24
add a comment |Â
up vote
1
down vote
GNU awk
solution:
awk -v FPAT='[^,"]+|"[^"]+"' '
NR==1; NR>1
for (i=1; i<=NF; i++)
if ($i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/)
sub(/-/, "", $i);
sub(/[0-9]/, "-&", $i);
printf "%s%s",$i,(i==NF? ORS:",")
' file.csv
-v FPAT='[^,"]+|"[^"]+"'
- regex pattern defining field value$i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/
- check if a field contains a number with trailing minus sign-
(number could be double-quoted)
The output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran FPAT requires gawk version 4. What is the output ofgawk --version
?
â fpmurphy1
Dec 6 '17 at 0:24
add a comment |Â
up vote
1
down vote
up vote
1
down vote
GNU awk
solution:
awk -v FPAT='[^,"]+|"[^"]+"' '
NR==1; NR>1
for (i=1; i<=NF; i++)
if ($i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/)
sub(/-/, "", $i);
sub(/[0-9]/, "-&", $i);
printf "%s%s",$i,(i==NF? ORS:",")
' file.csv
-v FPAT='[^,"]+|"[^"]+"'
- regex pattern defining field value$i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/
- check if a field contains a number with trailing minus sign-
(number could be double-quoted)
The output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
GNU awk
solution:
awk -v FPAT='[^,"]+|"[^"]+"' '
NR==1; NR>1
for (i=1; i<=NF; i++)
if ($i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/)
sub(/-/, "", $i);
sub(/[0-9]/, "-&", $i);
printf "%s%s",$i,(i==NF? ORS:",")
' file.csv
-v FPAT='[^,"]+|"[^"]+"'
- regex pattern defining field value$i~/^"?[0-9]+([0-9,.]+[0-9]+)?-"?$/
- check if a field contains a number with trailing minus sign-
(number could be double-quoted)
The output:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
answered Dec 5 '17 at 22:24
RomanPerekhrest
22.4k12145
22.4k12145
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran FPAT requires gawk version 4. What is the output ofgawk --version
?
â fpmurphy1
Dec 6 '17 at 0:24
add a comment |Â
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran FPAT requires gawk version 4. What is the output ofgawk --version
?
â fpmurphy1
Dec 6 '17 at 0:24
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
I see it's not working for the same data set I used. Still the negative remains at tailing.
â Kiran
Dec 5 '17 at 22:55
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran, that's not true ... and here's the screenshot ibb.co/jbzZ9b
â RomanPerekhrest
Dec 5 '17 at 23:02
@Kiran FPAT requires gawk version 4. What is the output of
gawk --version
?â fpmurphy1
Dec 6 '17 at 0:24
@Kiran FPAT requires gawk version 4. What is the output of
gawk --version
?â fpmurphy1
Dec 6 '17 at 0:24
add a comment |Â
up vote
0
down vote
CSV data requires a CSV parser. Ruby has one:
$ cat file.csv
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
$ ruby -rcsv -e '
CSV.foreach(ARGV.shift) do |row|
corrected = row.collect
puts CSV.generate_line(corrected)
end
' file.csv
-12,"-455,365.44",string with quotes-and with a comma in between,"4,432",6787
The CSV generator decided that the "string with quotes" did not need to be quoted because it does not contain a comma.
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
add a comment |Â
up vote
0
down vote
CSV data requires a CSV parser. Ruby has one:
$ cat file.csv
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
$ ruby -rcsv -e '
CSV.foreach(ARGV.shift) do |row|
corrected = row.collect
puts CSV.generate_line(corrected)
end
' file.csv
-12,"-455,365.44",string with quotes-and with a comma in between,"4,432",6787
The CSV generator decided that the "string with quotes" did not need to be quoted because it does not contain a comma.
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
add a comment |Â
up vote
0
down vote
up vote
0
down vote
CSV data requires a CSV parser. Ruby has one:
$ cat file.csv
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
$ ruby -rcsv -e '
CSV.foreach(ARGV.shift) do |row|
corrected = row.collect
puts CSV.generate_line(corrected)
end
' file.csv
-12,"-455,365.44",string with quotes-and with a comma in between,"4,432",6787
The CSV generator decided that the "string with quotes" did not need to be quoted because it does not contain a comma.
CSV data requires a CSV parser. Ruby has one:
$ cat file.csv
12-,"455,365.44-","string with quotes-and with a comma in between","4,432",6787
$ ruby -rcsv -e '
CSV.foreach(ARGV.shift) do |row|
corrected = row.collect
puts CSV.generate_line(corrected)
end
' file.csv
-12,"-455,365.44",string with quotes-and with a comma in between,"4,432",6787
The CSV generator decided that the "string with quotes" did not need to be quoted because it does not contain a comma.
answered Dec 5 '17 at 22:07
glenn jackman
46.8k265103
46.8k265103
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
add a comment |Â
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
I downvoted this answer because of the quote stripping.
â fpmurphy1
Dec 6 '17 at 4:07
add a comment |Â
up vote
0
down vote
awk solution that does not use gawk
FPAT:
NR==1;
NR > 1
$0 = $0","
while ($0)
( f ~ /^[0-9]+[.]?[0-9]+-$/ )
Output for supplied sample file is:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
add a comment |Â
up vote
0
down vote
awk solution that does not use gawk
FPAT:
NR==1;
NR > 1
$0 = $0","
while ($0)
( f ~ /^[0-9]+[.]?[0-9]+-$/ )
Output for supplied sample file is:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
add a comment |Â
up vote
0
down vote
up vote
0
down vote
awk solution that does not use gawk
FPAT:
NR==1;
NR > 1
$0 = $0","
while ($0)
( f ~ /^[0-9]+[.]?[0-9]+-$/ )
Output for supplied sample file is:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
awk solution that does not use gawk
FPAT:
NR==1;
NR > 1
$0 = $0","
while ($0)
( f ~ /^[0-9]+[.]?[0-9]+-$/ )
Output for supplied sample file is:
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
answered Dec 6 '17 at 2:41
fpmurphy1
2,231915
2,231915
add a comment |Â
add a comment |Â
up vote
0
down vote
With perl
, but not suitable for all sorts of csv
formats, works for given sample
$ perl -ne '@cols=/"[^"]+"|[^,]+/g;
map s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols;
print join ",", @cols' ip.csv
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
@cols=/"[^"]+"|[^,]+/g
save fields in arraymap s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols
change each element of array. The second substitution is used only if first doesn't succeed- change
(.*)
to([d,.]+)
to sort of restrict the matching to digits and,
and.
only. This would still match strings like..,..-
- change
print join ",", @cols
print the changed array with,
as separator
a bit of fun without using temp array
perl -ne 'print join ",", map /^"/ ? s/"(.*)-"$/"-$1"/r : s/(.*)-$/-$1/r /"[^"]+"|[^,]+/g'
add a comment |Â
up vote
0
down vote
With perl
, but not suitable for all sorts of csv
formats, works for given sample
$ perl -ne '@cols=/"[^"]+"|[^,]+/g;
map s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols;
print join ",", @cols' ip.csv
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
@cols=/"[^"]+"|[^,]+/g
save fields in arraymap s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols
change each element of array. The second substitution is used only if first doesn't succeed- change
(.*)
to([d,.]+)
to sort of restrict the matching to digits and,
and.
only. This would still match strings like..,..-
- change
print join ",", @cols
print the changed array with,
as separator
a bit of fun without using temp array
perl -ne 'print join ",", map /^"/ ? s/"(.*)-"$/"-$1"/r : s/(.*)-$/-$1/r /"[^"]+"|[^,]+/g'
add a comment |Â
up vote
0
down vote
up vote
0
down vote
With perl
, but not suitable for all sorts of csv
formats, works for given sample
$ perl -ne '@cols=/"[^"]+"|[^,]+/g;
map s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols;
print join ",", @cols' ip.csv
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
@cols=/"[^"]+"|[^,]+/g
save fields in arraymap s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols
change each element of array. The second substitution is used only if first doesn't succeed- change
(.*)
to([d,.]+)
to sort of restrict the matching to digits and,
and.
only. This would still match strings like..,..-
- change
print join ",", @cols
print the changed array with,
as separator
a bit of fun without using temp array
perl -ne 'print join ",", map /^"/ ? s/"(.*)-"$/"-$1"/r : s/(.*)-$/-$1/r /"[^"]+"|[^,]+/g'
With perl
, but not suitable for all sorts of csv
formats, works for given sample
$ perl -ne '@cols=/"[^"]+"|[^,]+/g;
map s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols;
print join ",", @cols' ip.csv
column 1, column 2, column 3, column 4, column 5
-12,"-455,365.44","string with quotes-and with a comma in between","4,432",6787
@cols=/"[^"]+"|[^,]+/g
save fields in arraymap s/"(.*)-"$/"-$1"/ or s/(.*)-$/-$1/ @cols
change each element of array. The second substitution is used only if first doesn't succeed- change
(.*)
to([d,.]+)
to sort of restrict the matching to digits and,
and.
only. This would still match strings like..,..-
- change
print join ",", @cols
print the changed array with,
as separator
a bit of fun without using temp array
perl -ne 'print join ",", map /^"/ ? s/"(.*)-"$/"-$1"/r : s/(.*)-$/-$1/r /"[^"]+"|[^,]+/g'
edited Dec 6 '17 at 6:12
answered Dec 6 '17 at 6:01
Sundeep
6,9511826
6,9511826
add a comment |Â
add a comment |Â
up vote
0
down vote
With sed
implementations supporting -E
, assuming the double quotes embedded in string fields are encoded as ""
and that those string fields don't contain newline characters:
sed -E '
:1
s/^(("[^"]*"|[^"])*,)?([0-9.]+)-(,|$)/1-34/;
s/^(("[^"]*"|[^"])*,)?"([0-9,.]+)-"(,|$)/1"-3"4/
t1' < file
Depending on the nature of the input, you may want to be stricter in matching the numbers. For instance ([0-9.]+)-
here would match on 12-
but also on ...-
. If that type of input may occur in the input, you could change it to ([0-9]*.?[0-9]+)-
for instance.
add a comment |Â
up vote
0
down vote
With sed
implementations supporting -E
, assuming the double quotes embedded in string fields are encoded as ""
and that those string fields don't contain newline characters:
sed -E '
:1
s/^(("[^"]*"|[^"])*,)?([0-9.]+)-(,|$)/1-34/;
s/^(("[^"]*"|[^"])*,)?"([0-9,.]+)-"(,|$)/1"-3"4/
t1' < file
Depending on the nature of the input, you may want to be stricter in matching the numbers. For instance ([0-9.]+)-
here would match on 12-
but also on ...-
. If that type of input may occur in the input, you could change it to ([0-9]*.?[0-9]+)-
for instance.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
With sed
implementations supporting -E
, assuming the double quotes embedded in string fields are encoded as ""
and that those string fields don't contain newline characters:
sed -E '
:1
s/^(("[^"]*"|[^"])*,)?([0-9.]+)-(,|$)/1-34/;
s/^(("[^"]*"|[^"])*,)?"([0-9,.]+)-"(,|$)/1"-3"4/
t1' < file
Depending on the nature of the input, you may want to be stricter in matching the numbers. For instance ([0-9.]+)-
here would match on 12-
but also on ...-
. If that type of input may occur in the input, you could change it to ([0-9]*.?[0-9]+)-
for instance.
With sed
implementations supporting -E
, assuming the double quotes embedded in string fields are encoded as ""
and that those string fields don't contain newline characters:
sed -E '
:1
s/^(("[^"]*"|[^"])*,)?([0-9.]+)-(,|$)/1-34/;
s/^(("[^"]*"|[^"])*,)?"([0-9,.]+)-"(,|$)/1"-3"4/
t1' < file
Depending on the nature of the input, you may want to be stricter in matching the numbers. For instance ([0-9.]+)-
here would match on 12-
but also on ...-
. If that type of input may occur in the input, you could change it to ([0-9]*.?[0-9]+)-
for instance.
answered Dec 6 '17 at 10:49
Stéphane Chazelas
282k53520854
282k53520854
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%2f409026%2ftrim-tailing-and-add-it-leading-for-numbers-in-shell%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
When you say string with quotes, is that double quotes? How are they encoded? By doubling the
"
like in most CSV formats? Or with"
as sometimes seen? Can the strings contain newline characters? It would be better to have a real example there.â Stéphane Chazelas
Dec 6 '17 at 10:40