Reputation
13,860
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
1 26 52
Impact
~581k people reached

17h
comment How to grep-inverse-match and exclude “before” and “after” lines
@AmelioVazquez-Reina - I don't think so as it still reads the input file twice (plus it does some sorting) as opposed to Mike's solution which only processes the file once.
17h
revised How to grep-inverse-match and exclude “before” and “after” lines
added 160 characters in body
19h
comment How to grep-inverse-match and exclude “before” and “after” lines
This would have the same problem as kos's (now deleted) solution as if there are duplicate lines in the input file and some of them fall outside the range and others are inside that range this will delete them all. Also, with multiple occurrences of pattern, if there are lines like -- in the input file (outside the ranges) this will delete them because the delimiter -- appears in grep's output when more then one line is matching pattern (the latter is highly unlikely but worth mentioning I guess).
19h
revised How to grep-inverse-match and exclude “before” and “after” lines
added 503 characters in body
20h
answered How to grep-inverse-match and exclude “before” and “after” lines
1d
comment parsing a huge file with awk and extracting a subset
The second command doesn't do what you think. It will process the whole file because the q after d is never executed. It will delete all lines not matching chr10 (in this case everything after the first block of chr10 lines) so you may think it quits but it doesn't. It's easy to see that if you add another chr10 line at the end of your file. It will be printed... so the scripts doesn't quit at the first line not matching chr10. A simpler way (imo) to quit at the first line not matching pattern is : sed -n '/^chr10[^0-9]/!q;p' ... no need for branching.
1d
comment Exec condition and xargs in Find simultaneously
@Masi - -print was just an example of action that would only be run if the previous action (exec grep) returns success; it doesn't do anything other than printing the file names that meet a certain condition.
1d
comment To sed if with and without conditions correct
Masi, I've already explained in my answer to your other question how to chain actions with find. See my updated post for a generic example but really, you should make an effort and try to understand how it works (the man page is your best friend). Believe me, it will pay off in the long run. Regards.
1d
revised Exec condition and xargs in Find simultaneously
added 425 characters in body
1d
comment figuring out the e “manufacturer” and “product” attributes using udev for pendrive
Does it show up with lsusb ?
2d
comment What is the cause of the sed error?
No. 1. -e is superfluous in this case as you're only using a single sed expression. 2. @User112638726's comment is misleading. The index after -i is supposed to be the suffix of the backup file, indeed but if only there was no space in-between. So -i index is interpreted as edit the file in place (make no backup) using the expression index - see my comment under the question... So the cause of this problem is that single space character. It has to be removed, e.g. -iindex or -i.index etc... for the command to work.
2d
comment What is the cause of the sed error?
sed interprets index after -i (because of the space between them) as a command and everything that follows as input files. In fact some seds will even edit your index.js in-place and prepend a line containing ndex to each line in your file because i in index is interpreted as a sed command (which means insert the text that follows before addressed lines but there are no addressed lines so it does it for every line).
2d
revised Exec condition and xargs in Find simultaneously
added 49 characters in body
2d
revised Exec condition and xargs in Find simultaneously
added 442 characters in body
2d
revised Exec condition and xargs in Find simultaneously
added 442 characters in body
2d
answered Exec condition and xargs in Find simultaneously
2d
comment Join multiple files with two blank lines?
The only downside with this (and cuonglm's) - I think - is when you need to concatenate many files (e.g 20 files) as you'll have to build up the command line args. Or when trying to concatenate all *.md's in a dir...
2d
revised Join multiple files with two blank lines?
added 231 characters in body
2d
comment Possible to read contents of an .iso without extracting or using isoinfo?
Well, if 7z l image.iso output isn't pretty enough I don't know...
Jun
28
comment awk and newlines in the input data
@A.B. - that means megapixels tag is missing (odd, as it's a composite tag derived from imagesize, does it print the size if you run exiftool -p '$imagesize' hUXnc.png ?); you could add -f to the command so that instead of that message a dash is printed for any missing tag but that's not the expected result...