Multiple values in one column value print in unix output
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
2nd row 3rd column values have multiple lines
output should be like below for 3rd columns values
Output
Venki
Venkata krishna Reddy
test
bash shell unix
add a comment |
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
2nd row 3rd column values have multiple lines
output should be like below for 3rd columns values
Output
Venki
Venkata krishna Reddy
test
bash shell unix
1
your question is not clear
– stack0114106
Nov 19 '18 at 12:06
Use{}
in the editor to mark the data.
– James Brown
Nov 19 '18 at 12:21
add a comment |
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
2nd row 3rd column values have multiple lines
output should be like below for 3rd columns values
Output
Venki
Venkata krishna Reddy
test
bash shell unix
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
2nd row 3rd column values have multiple lines
output should be like below for 3rd columns values
Output
Venki
Venkata krishna Reddy
test
bash shell unix
bash shell unix
edited Nov 19 '18 at 12:22
oguzismail
3,70531125
3,70531125
asked Nov 19 '18 at 11:48
siva tavvasiva tavva
82
82
1
your question is not clear
– stack0114106
Nov 19 '18 at 12:06
Use{}
in the editor to mark the data.
– James Brown
Nov 19 '18 at 12:21
add a comment |
1
your question is not clear
– stack0114106
Nov 19 '18 at 12:06
Use{}
in the editor to mark the data.
– James Brown
Nov 19 '18 at 12:21
1
1
your question is not clear
– stack0114106
Nov 19 '18 at 12:06
your question is not clear
– stack0114106
Nov 19 '18 at 12:06
Use
{}
in the editor to mark the data.– James Brown
Nov 19 '18 at 12:21
Use
{}
in the editor to mark the data.– James Brown
Nov 19 '18 at 12:21
add a comment |
1 Answer
1
active
oldest
votes
Check this out:
> cat broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna Reddy
date : Number : test
>
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt | awk -F":" ' { print $3 } '
Venki
Venkata krishna Reddy
test
>
Update1:
Based on new input:
$ cat date_pattern.txt
2018-11-18 03:05:17 : INFO : (571 | WRITER_1__1) : node02_p : WRT_8167 : Start loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1*_1) : node02_p : WRT_8035 : Load complete time: Sun Nov 18 03:05:16 2018
LOAD SUMMARY
============
WRT_8036 Target: DUAL (Instance Name: [DUAL1])
WRT_8044 No data loaded for this target
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_*_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
$ awk -F" " ' { if($0!~/^[0-9]{4}-[0-9]{2}/) { prev=prev$0; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' date_pattern.txt | perl -ne
' { if( /(.+?) WRT(.+?):(.+)/ and $x=$3 ) { print "$xn" } } ' > res4.txt
$
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
check the update
– stack0114106
Nov 19 '18 at 20:02
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374008%2fmultiple-values-in-one-column-value-print-in-unix-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Check this out:
> cat broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna Reddy
date : Number : test
>
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt | awk -F":" ' { print $3 } '
Venki
Venkata krishna Reddy
test
>
Update1:
Based on new input:
$ cat date_pattern.txt
2018-11-18 03:05:17 : INFO : (571 | WRITER_1__1) : node02_p : WRT_8167 : Start loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1*_1) : node02_p : WRT_8035 : Load complete time: Sun Nov 18 03:05:16 2018
LOAD SUMMARY
============
WRT_8036 Target: DUAL (Instance Name: [DUAL1])
WRT_8044 No data loaded for this target
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_*_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
$ awk -F" " ' { if($0!~/^[0-9]{4}-[0-9]{2}/) { prev=prev$0; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' date_pattern.txt | perl -ne
' { if( /(.+?) WRT(.+?):(.+)/ and $x=$3 ) { print "$xn" } } ' > res4.txt
$
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
check the update
– stack0114106
Nov 19 '18 at 20:02
|
show 2 more comments
Check this out:
> cat broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna Reddy
date : Number : test
>
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt | awk -F":" ' { print $3 } '
Venki
Venkata krishna Reddy
test
>
Update1:
Based on new input:
$ cat date_pattern.txt
2018-11-18 03:05:17 : INFO : (571 | WRITER_1__1) : node02_p : WRT_8167 : Start loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1*_1) : node02_p : WRT_8035 : Load complete time: Sun Nov 18 03:05:16 2018
LOAD SUMMARY
============
WRT_8036 Target: DUAL (Instance Name: [DUAL1])
WRT_8044 No data loaded for this target
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_*_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
$ awk -F" " ' { if($0!~/^[0-9]{4}-[0-9]{2}/) { prev=prev$0; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' date_pattern.txt | perl -ne
' { if( /(.+?) WRT(.+?):(.+)/ and $x=$3 ) { print "$xn" } } ' > res4.txt
$
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
check the update
– stack0114106
Nov 19 '18 at 20:02
|
show 2 more comments
Check this out:
> cat broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna Reddy
date : Number : test
>
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt | awk -F":" ' { print $3 } '
Venki
Venkata krishna Reddy
test
>
Update1:
Based on new input:
$ cat date_pattern.txt
2018-11-18 03:05:17 : INFO : (571 | WRITER_1__1) : node02_p : WRT_8167 : Start loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1*_1) : node02_p : WRT_8035 : Load complete time: Sun Nov 18 03:05:16 2018
LOAD SUMMARY
============
WRT_8036 Target: DUAL (Instance Name: [DUAL1])
WRT_8044 No data loaded for this target
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_*_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
$ awk -F" " ' { if($0!~/^[0-9]{4}-[0-9]{2}/) { prev=prev$0; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' date_pattern.txt | perl -ne
' { if( /(.+?) WRT(.+?):(.+)/ and $x=$3 ) { print "$xn" } } ' > res4.txt
$
Check this out:
> cat broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna
Reddy
date : Number : test
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt
Ravi : Siva : Venki
Siva : venki : Venkata krishna Reddy
date : Number : test
>
> awk -F":" ' { if(NF==1) { prev=prev$1; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' broken_3rd_col.txt | awk -F":" ' { print $3 } '
Venki
Venkata krishna Reddy
test
>
Update1:
Based on new input:
$ cat date_pattern.txt
2018-11-18 03:05:17 : INFO : (571 | WRITER_1__1) : node02_p : WRT_8167 : Start loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
2018-11-18 03:05:17 : INFO : (571 | WRITER_1*_1) : node02_p : WRT_8035 : Load complete time: Sun Nov 18 03:05:16 2018
LOAD SUMMARY
============
WRT_8036 Target: DUAL (Instance Name: [DUAL1])
WRT_8044 No data loaded for this target
2018-11-18 03:05:17 : INFO : (571 | WRITER_1_*_1) : node02_p : WRT_8168 : End loading table [DUAL] at: Sun Nov 18 03:05:16 2018
$ awk -F" " ' { if($0!~/^[0-9]{4}-[0-9]{2}/) { prev=prev$0; next } if( prev !~/^$/ && NR>1 ) { print prev ;} prev=$0 } END { print prev }' date_pattern.txt | perl -ne
' { if( /(.+?) WRT(.+?):(.+)/ and $x=$3 ) { print "$xn" } } ' > res4.txt
$
edited Nov 19 '18 at 20:02
answered Nov 19 '18 at 12:58
stack0114106stack0114106
3,4642418
3,4642418
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
check the update
– stack0114106
Nov 19 '18 at 20:02
|
show 2 more comments
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
check the update
– stack0114106
Nov 19 '18 at 20:02
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
thanks for the help … but my 3rd column values like below .. Load complete time: Sun Nov 18 03:05:16 2018 LOAD SUMMARY ============ WRT_8036 Target: DUAL (Instance Name: [DUAL1]) WRT_8044 No data loaded for this target
– siva tavva
Nov 19 '18 at 16:03
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
can you update it in the question.. the comment is not formatting correctly
– stack0114106
Nov 19 '18 at 16:08
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
in that case, splitting on : will not work, we have to check on 1st column with time stamp pattern and whatever comes in between should be rolled up to single row. please post it as a new question and share the link here..
– stack0114106
Nov 19 '18 at 16:21
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
ok.. paste the entire content in the comment itseld
– stack0114106
Nov 19 '18 at 16:30
check the update
– stack0114106
Nov 19 '18 at 20:02
check the update
– stack0114106
Nov 19 '18 at 20:02
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374008%2fmultiple-values-in-one-column-value-print-in-unix-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
your question is not clear
– stack0114106
Nov 19 '18 at 12:06
Use
{}
in the editor to mark the data.– James Brown
Nov 19 '18 at 12:21