63
votes
How can I do a 'change word' in Vim using the current paste buffer?
The Vim way is to learn how to intentionally use the yank, delete and other registers. Once you know these, you will easily find your own key sequences to do this.
Register "0 is the yank ...
26
votes
Accepted
Why does unbuffer -p mangle its input?
unbuffer is a tool to disable the buffering that some commands do when their output doesn't go to a terminal device.
When their output goes to a terminal device, commands assume there's an actual user ...
20
votes
Accepted
Configure Linux to regularly sync cached data to disk
How can I properly configure Linux to automatically sync regularly?
It already does so by default. See the vm.dirty_* sysctls in the vm sysctl section.
dirty_expire_centisecs
======================
...
13
votes
Accepted
What happens when a file that is 100% paged in to the page cache gets modified by another process
Continuous release then replaces /apps/EXE with a brand new executable.
This is the important part.
The way a new file is released is by creating a new file (e.g. /apps/EXE.tmp.20190907080000), ...
13
votes
Accepted
Why is mawk's output (STDOUT) buffered even though it is the terminal?
It's not that it's buffering its output.
mawk is the only utility that I know that buffers its input.
See also https://github.com/ThomasDickey/original-mawk/issues/41#issuecomment-241070898
In other ...
13
votes
Accepted
Can I make a pipe save data to disk instead of blocking until the reader can continue?
With the mbuffer utility:
producer | mbuffer -t -m 10G | consumer
This would cause mbuffer to use a memory-mapped file (the -t option) to buffer the potentially massive amount of data that producer ...
12
votes
Is there truth to the philosophy that you should sync; sync; sync; sync?
Old-timer here. Back in the glory days of TAPE, 3 rapid sync's in a row was a way to tell the TAPE controllers to not just un-link/unspool the tape-stream, but to rewind it as well, i.e. set the FD/...
11
votes
How can I do a 'change word' in Vim using the current paste buffer?
Go to visual mode by pressing v to capture the interesting text, and copy it by pressing y. Now capture the text you want delete, and press p for pasting.
10
votes
Is there truth to the philosophy that you should sync; sync; sync; sync?
There were certainly older UNIX systems for which it was safer to sync more than once, but not all on one command line as "sync; sync; sync". In the mid-80s, this became distilled to:
When ...
10
votes
Accepted
Why does tar's handling of stdout and - differ?
The difference in behaviour comes from tar: when writing, it applies a “blocking factor”, which by default uses 10240-byte records (that’s 2800 in hexadecimal). This happens even when compressing, ...
9
votes
stdin unbuffered
Unbuffering generally makes more sense for output. Output buffering is where an application holds on to its output before writing it until it has accumulated enough so as to minimize the number of I/...
9
votes
Configure Linux to regularly sync cached data to disk
As grawity’s answer explains, Linux does this automatically (and so does essentially every other OS). The sync command (and related system calls and library functions, like syncfs() or fsync()) just ...
7
votes
Is there a way to sync only one partition?
It is now possible with sync -f:
sync -f /mount/point
Excerpt from sync(1):
-f, --file-system
sync the file systems that contain the files
6
votes
Restrict size of buffer cache in Linux
If Ceph OSD is one separate process, you could use cgroups to control resources utilized by process:
Create a cgroup named like group1 with a memory limit (of 50GB, for example, other limits like CPU ...
6
votes
Accepted
How Do I Unbuffer The Output Passed From an Interactive Command Into a Pipeline Ending With `tee`?
Process substitution1 lets you transform a script typescript as it's written.
You can use script -q >(./dewtell >>outfile) brew args... instead of script -aq outfile brew args... to write a ...
5
votes
Accepted
Why do terminal emulators still have screen flicker?
I'd love to hear more details how exactly to trigger such prominent flickers, as I don't notice any while using my system.
On my system, VTE (the engine behind GNOME Terminal) can process about 10 MB/...
5
votes
Accepted
Do I need to take action regarding my Microarchitectural Data Sampling (MDS) status?
Can I do anything further to protect my system, and if so, what should my next steps be?
You can do something further to protect your system: you can disable SMT (hyperthreading). This is usually ...
5
votes
Buffering stdout separately from stderr
You should be able to do something like:
{
cmd 2>&3 3>&- |
awk ' {saved = saved $0 ORS}
END {printf "%s", saved}' 3>&-
} 3>&1
Here using awk to hold all ...
4
votes
Restrict size of buffer cache in Linux
You can also use vm.min_free_kbytes (/proc/sys/vm/min_free_kbytes) to prevent Linux kernel from using too much memory for buffering (you will need to experiment setting different values to find out ...
4
votes
Understanding inotifywait, pipes and buffers
If the output of inotifywait -q -m ./ is not redirected and you're running it in a terminal emulator, the output will go to a pty device. A pty device is a form of interprocess communication, a bit ...
4
votes
Accepted
How to correctly unbuffer a pipeline?
grep will output the lines that match a pattern, so it can't output anything until a full line (or end-of-file upon which, if the last line was not terminated, the behaviour varies depending on the ...
4
votes
Accepted
Does "mount -o remount,ro" flush filesystem buffers?
It should flush the cache, yes.
Arguably there is some fragility in this code path. It is not implemented in one place; it is implemented in each individual filesystem. E.g. ext2_remount() must ...
4
votes
How can I do a 'change word' in Vim using the current paste buffer?
I usually use this: yw to yank foo, then delete bar with dw, and as final step, put foo from register 0 which holds yanked text using "0p. Repeat putting with period (.) as needed.
Also, instead of ...
4
votes
Accepted
Block device cache v.s. a filesystem
When the program closes the block device file, Linux flushes the associated cache, forcing the program to wait. This only applies to the last close() however. It will not happen if something else ...
4
votes
Accepted
What are two caveats of line buffering in Unix?
Basically says, for example,
that if your program is writing text to the terminal,
a character at a time, very slowly,
and the line is (for example) 520 characters long,
then the library might write ...
4
votes
Accepted
What controls the buffering of stdout stderr?
Your programming language
This behaviour is an artefact of the C runtime library, and a requirement of the C programming language. Other programming languages have historically been built on top of ...
4
votes
Flush the pipe/printf buffers externally for already running process with known PID
Do you have access to the source of the running programs?
Forcing a flush of an arbitrary executable is, while not theoretically impossible, very difficult. You would need to find the fflush function ...
4
votes
What happens when a file that is 100% paged in to the page cache gets modified by another process
filbranden's answer is correct assuming the continuous release process does proper atomic replacement of files via rename. If it doesn't, but modifies the file in-place, things are different. However ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
buffer × 178linux × 37
pipe × 37
cache × 25
memory × 19
bash × 18
shell × 15
stdout × 15
io × 10
filesystems × 8
linux-kernel × 8
vim × 7
ram × 7
shell-script × 6
awk × 6
networking × 6
files × 6
kernel × 6
performance × 6
tail × 6
fifo × 6
grep × 5
block-device × 5
socket × 5
debian × 4