Reputation
Next tag badge:
399/400 score
103/80 answers
Badges
17 139 280
Newest
 Nice Answer
Impact
~4.1m people reached

1h
comment Insert “return 0” between all braces in a file?
@Adam, It inserts a tab character. tab characters don't have width, they are control characters like CR or BS. For text editors or terminals, they move the cursor to the next tab stop. In vim you can change the number of columns between tab stops with the ts/tabstop option.
7h
comment How to turn Diff command into bash script with prompt
Note sort | uniq -d (or -D for all of them) to see duplicated lines. To say "end-of-file" when entering lines in a terminal, type CTRL-D. CTRL-Z is to suspend the current job.
13h
comment How can I quickly sum all numbers in a file?
@TomFenech, the POSIX syntax for awk requires that those pattern/action items be separated by either ";" or "newline", so you may find awk implementations where it fails without this ";".
1d
comment How can I quickly sum all numbers in a file?
@slm, this is a new user with one of the best answers (from a technical stand point) and he gets two downvotes and a negative comment. Not a very warm welcome.
1d
comment How can I quickly sum all numbers in a file?
@slm, that answer is not any more or less verbose than the other answers here and is self explanatory. It also has the advantage of working with input like time=1.4e5sec
1d
comment source multiple files and output one file
Is the order of the output that matters or the order of the assignment? (is it OK for custom to show before name in the output as long as last is star and not '')?
1d
comment Stateful uniq functionality
sort limits its memory usage by resorting to temporary files. The awk solution stores all unique lines in memory so could end up using more memory than sort would.
2d
comment Move a range of words to the end of the string
Can there be more than one comment= and/or fruit in that string? Do you need that process for every line of a file, or just in a string stored in a shell variable? Can that string contain newline characters?
2d
comment how do I trim each line in bash?
@don_crissti ...and/or has lines starting with - and followed by combinations of 1 or more e, E or n characters, and/or contains NUL characters. Also, a non-terminated line after the last newline will be skipped.
2d
comment man page search - how can I turn off the highlighting after matches found?
@user4668401, man has nothing to do with bash. bash is a command to interpret command-lines (a command-line language interpreter), man is a command to read manual pages.
2d
comment Substrings in shell script
(with mksh, you need the -U option for ${var:offset:length} to work with characters as opposed to bytes in UTF-8 locales).
2d
comment Substrings in shell script
That syntax is also available in zsh's ksh and mksh since version 30.1 (2007).
2d
comment Substrings in shell script
You may want to read Why is using a shell loop to process text considered bad practice?. You've fallen in almost every trap there.
2d
comment How to rename multiple files by removing the extension?
Also note that it replaces the first occurrence of .oldext within the file name, not necessarily the extension (foo.oldextasy.oldext would be renamed to footasy.oldext).
2d
comment How to rename multiple files by removing the extension?
That assumes the util-linux implementation of rename which is incompatible with (and much more limited than) the traditional rename command from perl.
2d
comment Is there a way of listing all the instances when a particular file was modified/edited?
beside nilfs2, zfs and btrfs could be used to take snapshots every few minutes.
2d
comment Is there a way of listing all the instances when a particular file was modified/edited?
You could use auditd to log all write/truncate/fallocate... system calls to the file (not operations over mmap though)
2d
comment Is there a way of listing all the instances when a particular file was modified/edited?
You can also mount a svn repo over webdav with autoversioning upon writes
2d
comment Is there a way of listing all the instances when a particular file was modified/edited?
To add to the list, I believe that there are some fuse based versioning file systems (potentially using git underneath)
2d
comment How to check if pipe is empty
read will also return false if the input is non-empty but contains no newline character, read does some processing on its input and may read more than one line unless you call it as IFS= read -r line. echo can't be used for arbitrary data.