[ale] Fun bash thing
Jim Kinney
jim.kinney at gmail.com
Sat Nov 9 10:35:26 EST 2024
I've done similar but usually output to a different file using the
some-command as an extractor/processor often for line-by-line mangling. Did
not know it dumps the entire input file into memory first. Hmm. That has
possibilities as well as potential gotchas related to size. Usually the
memory is not a problem but if the system is already in heavy use it could
be impactful.
Nice. Very nice.
My latest fun toy is a grep to find what is in fileA that's not in fileB
with one item per line for each.
grep -Fvxf fileB fileA
Really useful for finding kernel sysctl setting changes between large
systems. Thousand line files are ms times.
On Sat, Nov 9, 2024, 10:09 AM Charles Shapiro via Ale <ale at ale.org> wrote:
> Learned this off mastodon today.
>
> **
>
> Here's an interesting Bash pattern I just used for the first time.
>
> some-command <<<"$(< some/file)" >some/file
>
> It reads all of some/file into memory before writing it to some-command's
> stdin. This lets some-command's stdout be redirected to some/file without
> the usual problems of reading/writing from the same file.
>
> **
>
>
> H/T to @trs at metasocial.com <trs at metasocial.com>
>
>
> -- CHS
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> https://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.ale.org/pipermail/ale/attachments/20241109/936c8041/attachment.htm>
More information about the Ale
mailing list