Search Results

Search: Posts Made By: jyu3
3,410
Posted By jyu3
Jotne, This is an excellent excellent...
Jotne,

This is an excellent excellent tutorial of awk! This the first time I actually understand how the code works instead of just copy and paste it in my script. I couldn't be more thankful.
...
3,410
Posted By jyu3
Thanks so much, guys. You guys are genius!! ...
Thanks so much, guys. You guys are genius!!
All the solutions work. But I need to study each of them to see how they work.
Awk code is so hard to understand. It's like a magic to me.
3,410
Posted By jyu3
Replace and add line in file with line in another file based on matching string
Hi,

I want to achieve something similar to what described in another post:


The difference is I want to add the line if the pattern is not found.

File 1:
A123, valueA, valueB
B234,...
1,719
Posted By jyu3
You are right! Thank you very much for the...
You are right!
Thank you very much for the help.
I was making things too complicated.....

For the record
awk -F \| '/# @D/ {print $5} {print}' tst_geo.gmt > ttt.txt
1,719
Posted By jyu3
Thanks for the quick reply. Do you mean: awk...
Thanks for the quick reply.
Do you mean:
awk -F \| -v pat="# @D" '{a[NR]=$0;}END{for(i=1;i<=NR;i++){if(a[i] ~ pat ){print $5"\n" a[i];}else{print a[i];}}}' tst_geo.gmt >output.txt

I tried that...
1,719
Posted By jyu3
Insert certain field of matched pattern line above pattern
Hello every,

I am stuck in a problem. I have file like this. I want to add the fifth field of the match pattern line above the lines starting with "# @D". The delimiter is "|"
eg
>
#...
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 09:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy