5,859 reputation
1239
bio website toggle.be/~ta
location Denmark
age 37
visits member for 2 years, 4 months
seen 18 hours ago

I'm trained in computer science engineering, but have a wide range of other interests as well.


19h
comment How to copy rows of different files and paste column-wise?
A similar question is answered here, but with focus on shell processing.
Aug
11
comment Only return the matched string in sed
@danielsokolowski: this example uses basic regular expressions (BRE) and thus capture groups are noted with escaped parentheses. If you add -r to the above you should get an error saying "invalid reference". What version of sed are you using?
Jun
23
comment UNIX paste columns and insert zero's for all missing values
@biobudhan: No this produces space separated columns. I updated the answer to (more correctly) use OFS when generating the table. With this change you can specify the output separator by setting OFS on the command line, either awk -v OFS='\t' -f merge.awk FILES or as a post argument awk -f merge.awk OFS='\t' FILES.
Jun
22
comment Remove comma between the quotes only in a comma delimited file
@CocoaEv: It executes { print $0 }. I added that to the explanation as well.
Jun
12
comment UNIX paste columns and insert zero's for all missing values
@biobudhan: Note that this solution does not preserve the columns, e.g. numbers from the pqr record will always end up in the first column no matter the order of the file arguments. This may or may not be a problem depending on what the you want.
Apr
3
comment Merge 2 files based on all values of the first column of the first file
join can still work if the line order is not important, see my answer below.
Mar
25
comment How to find and replace a field column value in UNIX
@MeghanaPrakash: Did you try with the latest version? I recently added an ending anchor as suggested by Stephane.
Mar
25
comment How to find and replace a field column value in UNIX
@StephaneChazelas: Interesting, this seems to be because of overlapping matches. It can be fixed by looping, as you have already found.
Mar
25
comment How to find and replace a field column value in UNIX
@StephaneChazelas: good point, I added a terminal anchor as well, thanks.
Mar
25
comment How to find and replace a field column value in UNIX
@MeghanaPrakash: This was tested with GNU sed. Which version of sed are you using?
Nov
8
comment Is it possible to get a hardcopy in Tmux?
@Moondoggy: The semi-colons should indeed be escaped, thanks.
Oct
17
comment With grep, how can I match a pattern and invert match another pattern?
@RahulPatil: I see what you mean now, Option 1 assumes that a --\n delimiter is between each matched group, which is not there if the groups are adjacent to each other. How adjacent groups should be handled is task-specific, so this is not necessarily wrong. Option 2 does not depend on the separator and is not affected.
Oct
17
comment With grep, how can I match a pattern and invert match another pattern?
@RahulPatil: could you rephrase or add more detail to your question? I don't understand what you are asking.
Oct
15
comment Align text to center with padding on both sides
@Avidanborisov: nice solution, feel free to post it as an answer, or, if you prefer, add it to this answer
Aug
20
comment How to grep for pipe |
@StephaneChazelas: thank you for pointing this out, I was not aware of it. I corrected the text.
May
19
comment awk + paste for cleaning up PATH?
@StephaneChazelas: That is indeed a much better choice, I didn't know about that option. Thanks.
May
19
comment awk + paste for cleaning up PATH?
@PredragPunosevac: I think the backslashes are there to prevent csh from doing history expansion on the exclamation mark.
May
8
comment Why does (GNU?) parallel fail silently, and how do I fix it?
You can also add --gnu to $HOME/.parallel/config.
May
4
comment How can I separate these two outputs using awk command
-P uses Perl regular expressions.
Apr
30
comment How can I prevent 'grep' from showing up in ps results?
Same question on Serverfault and Superuser.