Replace @@@ and NotApplicable string and redirect output to other file? [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
put tab before every output line on AIX/ksh
2 answers
How to work with multiple sed commands in aix?
2 answers
I'm using IBM AIX which doesn't have much support like sed -i
and sed with t
is not working in my case.
I would like to replace replace NotApplicable
string with a single space ' '
then replace @@@
multi-char-delimiter with a tab delimiter
, in a specified order using single command be it awk, or sed.
I tried using sed as following but it didn't work. Couldn't add search and replace for NotApplicable with a ' ' single space in below command.
sed 's/@@@/t/g' file.csv > file.xls
Sample data.
cola@@@colb@@@colbc
test@@@test@@@test
test@@@NotApplicable@@@test
123@@@145@@@567
333@@@444@@@NotApplicable
cola colb colbc
test test test
test test
123 145 567
333 444
text-processing awk sed aix
marked as duplicate by Jeff Schaller, JigglyNaga, Archemar, X Tian, elbarna Nov 28 at 14:51
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
put tab before every output line on AIX/ksh
2 answers
How to work with multiple sed commands in aix?
2 answers
I'm using IBM AIX which doesn't have much support like sed -i
and sed with t
is not working in my case.
I would like to replace replace NotApplicable
string with a single space ' '
then replace @@@
multi-char-delimiter with a tab delimiter
, in a specified order using single command be it awk, or sed.
I tried using sed as following but it didn't work. Couldn't add search and replace for NotApplicable with a ' ' single space in below command.
sed 's/@@@/t/g' file.csv > file.xls
Sample data.
cola@@@colb@@@colbc
test@@@test@@@test
test@@@NotApplicable@@@test
123@@@145@@@567
333@@@444@@@NotApplicable
cola colb colbc
test test test
test test
123 145 567
333 444
text-processing awk sed aix
marked as duplicate by Jeff Schaller, JigglyNaga, Archemar, X Tian, elbarna Nov 28 at 14:51
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If you're just doing this from the command line (not writing a script which should pass code review ;-)) you can simply enter the tab manually with Ctrl-v Tab. (your command will look likesed s/@@@/ /g ...
)
– mosvy
Nov 28 at 3:32
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
put tab before every output line on AIX/ksh
2 answers
How to work with multiple sed commands in aix?
2 answers
I'm using IBM AIX which doesn't have much support like sed -i
and sed with t
is not working in my case.
I would like to replace replace NotApplicable
string with a single space ' '
then replace @@@
multi-char-delimiter with a tab delimiter
, in a specified order using single command be it awk, or sed.
I tried using sed as following but it didn't work. Couldn't add search and replace for NotApplicable with a ' ' single space in below command.
sed 's/@@@/t/g' file.csv > file.xls
Sample data.
cola@@@colb@@@colbc
test@@@test@@@test
test@@@NotApplicable@@@test
123@@@145@@@567
333@@@444@@@NotApplicable
cola colb colbc
test test test
test test
123 145 567
333 444
text-processing awk sed aix
This question already has an answer here:
put tab before every output line on AIX/ksh
2 answers
How to work with multiple sed commands in aix?
2 answers
I'm using IBM AIX which doesn't have much support like sed -i
and sed with t
is not working in my case.
I would like to replace replace NotApplicable
string with a single space ' '
then replace @@@
multi-char-delimiter with a tab delimiter
, in a specified order using single command be it awk, or sed.
I tried using sed as following but it didn't work. Couldn't add search and replace for NotApplicable with a ' ' single space in below command.
sed 's/@@@/t/g' file.csv > file.xls
Sample data.
cola@@@colb@@@colbc
test@@@test@@@test
test@@@NotApplicable@@@test
123@@@145@@@567
333@@@444@@@NotApplicable
cola colb colbc
test test test
test test
123 145 567
333 444
This question already has an answer here:
put tab before every output line on AIX/ksh
2 answers
How to work with multiple sed commands in aix?
2 answers
text-processing awk sed aix
text-processing awk sed aix
edited Nov 28 at 9:19
mosvy
5,011323
5,011323
asked Nov 28 at 1:44
mr_eclair
1,80131416
1,80131416
marked as duplicate by Jeff Schaller, JigglyNaga, Archemar, X Tian, elbarna Nov 28 at 14:51
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jeff Schaller, JigglyNaga, Archemar, X Tian, elbarna Nov 28 at 14:51
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If you're just doing this from the command line (not writing a script which should pass code review ;-)) you can simply enter the tab manually with Ctrl-v Tab. (your command will look likesed s/@@@/ /g ...
)
– mosvy
Nov 28 at 3:32
add a comment |
If you're just doing this from the command line (not writing a script which should pass code review ;-)) you can simply enter the tab manually with Ctrl-v Tab. (your command will look likesed s/@@@/ /g ...
)
– mosvy
Nov 28 at 3:32
If you're just doing this from the command line (not writing a script which should pass code review ;-)) you can simply enter the tab manually with Ctrl-v Tab. (your command will look like
sed s/@@@/ /g ...
)– mosvy
Nov 28 at 3:32
If you're just doing this from the command line (not writing a script which should pass code review ;-)) you can simply enter the tab manually with Ctrl-v Tab. (your command will look like
sed s/@@@/ /g ...
)– mosvy
Nov 28 at 3:32
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Translating Gilles' answer to this situation, it'd be:
sed $'s/@@@/t/g; s/NotApplicable/ /g' file.csv > file.xls
This uses ANSI-C quoting to allow interpretation of t
as a TAB; everything else inside the quotes is the existing sed
command.
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
1
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
2
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for$'...'
.
– mosvy
Nov 28 at 9:30
|
show 3 more comments
up vote
1
down vote
There are probably more obvious ways to do it, but one way to generate any character on any unix system is with tr(1):
tab=`echo t | tr t '11'`
sed "s/NotApplicable/ /g; s/@@@/$tab/g" file.csv > file.xls
Notice the double quotes around the sed
command.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Translating Gilles' answer to this situation, it'd be:
sed $'s/@@@/t/g; s/NotApplicable/ /g' file.csv > file.xls
This uses ANSI-C quoting to allow interpretation of t
as a TAB; everything else inside the quotes is the existing sed
command.
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
1
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
2
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for$'...'
.
– mosvy
Nov 28 at 9:30
|
show 3 more comments
up vote
1
down vote
Translating Gilles' answer to this situation, it'd be:
sed $'s/@@@/t/g; s/NotApplicable/ /g' file.csv > file.xls
This uses ANSI-C quoting to allow interpretation of t
as a TAB; everything else inside the quotes is the existing sed
command.
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
1
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
2
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for$'...'
.
– mosvy
Nov 28 at 9:30
|
show 3 more comments
up vote
1
down vote
up vote
1
down vote
Translating Gilles' answer to this situation, it'd be:
sed $'s/@@@/t/g; s/NotApplicable/ /g' file.csv > file.xls
This uses ANSI-C quoting to allow interpretation of t
as a TAB; everything else inside the quotes is the existing sed
command.
Translating Gilles' answer to this situation, it'd be:
sed $'s/@@@/t/g; s/NotApplicable/ /g' file.csv > file.xls
This uses ANSI-C quoting to allow interpretation of t
as a TAB; everything else inside the quotes is the existing sed
command.
edited Nov 28 at 2:00
answered Nov 28 at 1:58
Jeff Schaller
37k1052121
37k1052121
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
1
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
2
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for$'...'
.
– mosvy
Nov 28 at 9:30
|
show 3 more comments
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
1
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
2
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for$'...'
.
– mosvy
Nov 28 at 9:30
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
I like to replace NotApplicable to single space ' ' as well using same sed.
– mr_eclair
Nov 28 at 1:59
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
see edited Answer
– Jeff Schaller
Nov 28 at 2:00
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
Didn't work in my case.
– mr_eclair
Nov 28 at 2:04
1
1
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
What does "didn't work" mean? The changes don't happen? You get an error?
– Jeff Schaller
Nov 28 at 2:07
2
2
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for
$'...'
.– mosvy
Nov 28 at 9:30
@JeffSchaller I don't think that the ksh88 (?) on AIX has support for
$'...'
.– mosvy
Nov 28 at 9:30
|
show 3 more comments
up vote
1
down vote
There are probably more obvious ways to do it, but one way to generate any character on any unix system is with tr(1):
tab=`echo t | tr t '11'`
sed "s/NotApplicable/ /g; s/@@@/$tab/g" file.csv > file.xls
Notice the double quotes around the sed
command.
add a comment |
up vote
1
down vote
There are probably more obvious ways to do it, but one way to generate any character on any unix system is with tr(1):
tab=`echo t | tr t '11'`
sed "s/NotApplicable/ /g; s/@@@/$tab/g" file.csv > file.xls
Notice the double quotes around the sed
command.
add a comment |
up vote
1
down vote
up vote
1
down vote
There are probably more obvious ways to do it, but one way to generate any character on any unix system is with tr(1):
tab=`echo t | tr t '11'`
sed "s/NotApplicable/ /g; s/@@@/$tab/g" file.csv > file.xls
Notice the double quotes around the sed
command.
There are probably more obvious ways to do it, but one way to generate any character on any unix system is with tr(1):
tab=`echo t | tr t '11'`
sed "s/NotApplicable/ /g; s/@@@/$tab/g" file.csv > file.xls
Notice the double quotes around the sed
command.
edited Nov 28 at 9:18
answered Nov 28 at 9:12
mosvy
5,011323
5,011323
add a comment |
add a comment |
If you're just doing this from the command line (not writing a script which should pass code review ;-)) you can simply enter the tab manually with Ctrl-v Tab. (your command will look like
sed s/@@@/ /g ...
)– mosvy
Nov 28 at 3:32