Earlier quoted context omitted.
> Watch out, that's a Linux-ism and macOS's sed It's GNU sed vs (Free)BSD sed, which are different enhancements of the POSIX standards for sed that went in different design directions. One could Homebrew/macports install gnu-sed on macOS to get a GNU version to write Linux-portable scripts as-needed.
Plan9 sed has no -i option. Older versions of NetBSD will not have it either. I never understood the point of the -i option other than to conserve keystrokes. A temporary file is still created then removed; the -i option only saves the user from having to specify it. Maybe the intent is it is only for "one-off" use, not for use in scripts. This will work for GNU, BSD and Plan9: sed -n 's/old/new/wfile.tmp' file mv fi…
Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
81–90 of 114 posts
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#82Earlier quoted context omitted.
What do you mean?
How many major versions of Perl do you know about? What is the distribution of these different versions of Perl across various OSes and OS versions? Hint: Lots of backward-incompatible changes tend to get made around different major versions. Having Perl 4 is not like having Perl 5 which is not like Perl 6.
Are there any contemporary distros that have the "perl" exectuable that is not Perl 5?
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#83Earlier quoted context omitted.
I had been in the habit of symlinking ~/.bash_history to /dev/null to avoid AFS/NFS writes on every local command execution. When I moved over to the financial industry, it didn't occur to me that such a symlink might look like an attempt to evade monitoring. A year or two in, I realized it didn't look good, but it had clearly been made my first week on the job, so I just left it in place for over 10 years rather tha…
It's simpler to use a tmpfs for this purpose. $XDG_RUNTIME_DIR is already available, on modern Linux versions.
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#84I love these one-liners. It's also about knowing your tools better. I hadn't known about `look` [0], which is great. The writer looks to be a bioinformatician, so it might be a bit out of scope, but I also found `socat` [1] quite a good serial communication helper tool. [0] https://man7.org/linux/man-pages/man1/look.1.html [1] https://linux.die.net/man/1/socat
I've used `look` for years when I'm not sure how to spell some obscure word and I'm in a context where there isn't a built-in spellchecker (e.g. editing source code). I was today years old when I learned that looking up words from the system dictionary is just the convenient default and you can use it to search lines from any file.
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#85Earlier quoted context omitted.
You could use hardlinks for this, though (as long as both places are in the same filesystem). Then when you're finishes you just delete the old folder.
Huh. As a hardlink avoider, I never even thought of this. (I don't have a good reason for avoiding hardlinks - it's mainly just because I didn't grok them enough to predict their behavior. When you teach yourself, you gotta expect some gaps!) Thanks for the suggestion.
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#86Earlier quoted context omitted.
>a copy of your original directory, with only the modified files actually taking up space What's the use case for this sort of thing?
At work, we have a codebase that is used by numerous projects. The solution for project specific changes is 'checkout the repo, and make your changes locally'. What that has turned into is 'checkout the repo and make a new directory structure that symlinks everything back to the original'. The keeps the maintenance burden relatively small as you can easily update the base version, and only need to worry about the fil…
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#87Not one-liners, but some of the tools that I have found helpful for working with large bash codebases are: - shellcheck and shfmt for linting and formatting - sub for organizing subcommands - bashdb for debugging scripts interactively via the VSCode extension I'm still missing a way to share modules with others like it can be done with ansible/terraform, but I have not found an optimal way to do it yet. [shellcheck]…
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#88I love these one-liners. It's also about knowing your tools better. I hadn't known about `look` [0], which is great. The writer looks to be a bioinformatician, so it might be a bit out of scope, but I also found `socat` [1] quite a good serial communication helper tool. [0] https://man7.org/linux/man-pages/man1/look.1.html [1] https://linux.die.net/man/1/socat
This particular man page is from 2015 or (likely) earlier.
Official docs: http://www.dest-unreach.org/socat/doc/socat.html
Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#89I love these one-liners. It's also about knowing your tools better. I hadn't known about `look` [0], which is great. The writer looks to be a bioinformatician, so it might be a bit out of scope, but I also found `socat` [1] quite a good serial communication helper tool. [0] https://man7.org/linux/man-pages/man1/look.1.html [1] https://linux.die.net/man/1/socat
On my system:
$ look asce
Ascella
Ascella's
$ grep -i ^asce /usr/share/dict/words
Ascella
Ascella's
ascend
ascendancy
ascendancy's
…Re: Bash-oneliner: A collection of handy Bash one-liners and terminal tricks
#90> Ctrl + x + Ctrl + e : launch editor defined by $EDITOR to input your command. Useful for multi-line commands. -- Great, I was just trying to remember that key combination the other day. Just got back to work after being for awhile for a child bonding leave.