6,029 reputation
1342
bio website toggle.be/~ta
location Denmark
age 37
visits member for 2 years, 7 months
seen Nov 21 at 11:58

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


Nov
13
comment Output part of each line to a separate file
@StéphaneChazelas: I see, and it has been there for a while. I did not know about this, thanks for telling me.
Nov
13
comment Output part of each line to a separate file
@glennjackman: This was just an interesting alternative way of doing it. If the input is large, awk is probably the most efficient tool to use. You are of course right about not spawning sh for each line, I have added the pipe-option as an alternative.
Nov
13
comment Output part of each line to a separate file
If there are many lines, all available file descriptors will be used, so you should probably add a close($1".seq").
Oct
27
comment Print a line only if the next line does NOT contain a particular match
@lmmx: It is needed because otherwise the capture group needs to be escaped, and the same goes for the + quantifier.
Oct
23
comment How can I do the `history` command and not have line numbers so I can copy multiple line commands?
@Fedir: Interesting, which shell is this under?
Aug
29
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.