How to reformat text in a file to another direction?
Clash Royale CLAN TAG#URR8PPP
up vote
7
down vote
favorite
I have table in the current format:
Lead:Arrow1:Arrow2:Arrow3
Follow:Arrow4:Arrow5:Arrow6:Arrow7:Arrow8:Arrow9
I want to turn this to the
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
I tried awk
:
$(awk -F":" '/Lead/ print NF-1' $f)
$(awk -F":" '/Follow/ print NF-1' $f)
but it didn't work. How can I do it in awk
or any other method?
awk text-formatting
New contributor
add a comment |Â
up vote
7
down vote
favorite
I have table in the current format:
Lead:Arrow1:Arrow2:Arrow3
Follow:Arrow4:Arrow5:Arrow6:Arrow7:Arrow8:Arrow9
I want to turn this to the
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
I tried awk
:
$(awk -F":" '/Lead/ print NF-1' $f)
$(awk -F":" '/Follow/ print NF-1' $f)
but it didn't work. How can I do it in awk
or any other method?
awk text-formatting
New contributor
3
Possible duplicate of Print each field of CSV on newline without knowing number of fields
â Ã±ÃÂsýù÷
8 hours ago
add a comment |Â
up vote
7
down vote
favorite
up vote
7
down vote
favorite
I have table in the current format:
Lead:Arrow1:Arrow2:Arrow3
Follow:Arrow4:Arrow5:Arrow6:Arrow7:Arrow8:Arrow9
I want to turn this to the
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
I tried awk
:
$(awk -F":" '/Lead/ print NF-1' $f)
$(awk -F":" '/Follow/ print NF-1' $f)
but it didn't work. How can I do it in awk
or any other method?
awk text-formatting
New contributor
I have table in the current format:
Lead:Arrow1:Arrow2:Arrow3
Follow:Arrow4:Arrow5:Arrow6:Arrow7:Arrow8:Arrow9
I want to turn this to the
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
I tried awk
:
$(awk -F":" '/Lead/ print NF-1' $f)
$(awk -F":" '/Follow/ print NF-1' $f)
but it didn't work. How can I do it in awk
or any other method?
awk text-formatting
awk text-formatting
New contributor
New contributor
edited 17 mins ago
peterh
4,04792755
4,04792755
New contributor
asked 9 hours ago
kashef
383
383
New contributor
New contributor
3
Possible duplicate of Print each field of CSV on newline without knowing number of fields
â Ã±ÃÂsýù÷
8 hours ago
add a comment |Â
3
Possible duplicate of Print each field of CSV on newline without knowing number of fields
â Ã±ÃÂsýù÷
8 hours ago
3
3
Possible duplicate of Print each field of CSV on newline without knowing number of fields
â Ã±ÃÂsýù÷
8 hours ago
Possible duplicate of Print each field of CSV on newline without knowing number of fields
â Ã±ÃÂsýù÷
8 hours ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
12
down vote
accepted
You can use tr
as follows:
<file tr ":" "n"
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
or awk
as follows:
<file awk 'gsub(/:/,"n")1'
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
2
Nice, with GNU awk you could also writeawk -v RS='[:n]' 1
â user000001
7 hours ago
add a comment |Â
up vote
0
down vote
Another super-simple solution would be to convert the :
s to spaces with sed, and then print the words with echo
in a for
loop:
for i in $(sed 's/:/ /g')
do
echo $i
done
This script works from stdin to stdout.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
12
down vote
accepted
You can use tr
as follows:
<file tr ":" "n"
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
or awk
as follows:
<file awk 'gsub(/:/,"n")1'
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
2
Nice, with GNU awk you could also writeawk -v RS='[:n]' 1
â user000001
7 hours ago
add a comment |Â
up vote
12
down vote
accepted
You can use tr
as follows:
<file tr ":" "n"
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
or awk
as follows:
<file awk 'gsub(/:/,"n")1'
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
2
Nice, with GNU awk you could also writeawk -v RS='[:n]' 1
â user000001
7 hours ago
add a comment |Â
up vote
12
down vote
accepted
up vote
12
down vote
accepted
You can use tr
as follows:
<file tr ":" "n"
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
or awk
as follows:
<file awk 'gsub(/:/,"n")1'
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
You can use tr
as follows:
<file tr ":" "n"
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
or awk
as follows:
<file awk 'gsub(/:/,"n")1'
Lead
Arrow1
Arrow2
Arrow3
Follow
Arrow4
Arrow5
Arrow6
Arrow7
Arrow8
Arrow9
edited 8 hours ago
answered 9 hours ago
Goro
7,94153777
7,94153777
2
Nice, with GNU awk you could also writeawk -v RS='[:n]' 1
â user000001
7 hours ago
add a comment |Â
2
Nice, with GNU awk you could also writeawk -v RS='[:n]' 1
â user000001
7 hours ago
2
2
Nice, with GNU awk you could also write
awk -v RS='[:n]' 1
â user000001
7 hours ago
Nice, with GNU awk you could also write
awk -v RS='[:n]' 1
â user000001
7 hours ago
add a comment |Â
up vote
0
down vote
Another super-simple solution would be to convert the :
s to spaces with sed, and then print the words with echo
in a for
loop:
for i in $(sed 's/:/ /g')
do
echo $i
done
This script works from stdin to stdout.
add a comment |Â
up vote
0
down vote
Another super-simple solution would be to convert the :
s to spaces with sed, and then print the words with echo
in a for
loop:
for i in $(sed 's/:/ /g')
do
echo $i
done
This script works from stdin to stdout.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Another super-simple solution would be to convert the :
s to spaces with sed, and then print the words with echo
in a for
loop:
for i in $(sed 's/:/ /g')
do
echo $i
done
This script works from stdin to stdout.
Another super-simple solution would be to convert the :
s to spaces with sed, and then print the words with echo
in a for
loop:
for i in $(sed 's/:/ /g')
do
echo $i
done
This script works from stdin to stdout.
answered 16 mins ago
peterh
4,04792755
4,04792755
add a comment |Â
add a comment |Â
kashef is a new contributor. Be nice, and check out our Code of Conduct.
kashef is a new contributor. Be nice, and check out our Code of Conduct.
kashef is a new contributor. Be nice, and check out our Code of Conduct.
kashef 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%2funix.stackexchange.com%2fquestions%2f474240%2fhow-to-reformat-text-in-a-file-to-another-direction%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
3
Possible duplicate of Print each field of CSV on newline without knowing number of fields
â Ã±ÃÂsýù÷
8 hours ago