Questions tagged [read]
`read` is a shell utility used for reading strings from the standard input stream, or from a file descriptor.
28
questions with no upvoted or accepted answers
2
votes
0answers
89 views
Linux AHCI/ATA read errors not reported
After a recent OS upgrade (to current Tumbleweed, Linux Kernel 4.16.0 from April 4th), when reading from a faulty hard disk or from damaged/scratched DVDs, I don't get anymore read errors in the ...
2
votes
0answers
117 views
'less' with header line kept at the top
Just like this question: I want to open a file with e.g., less -Sx32 file.dat, but as I scroll down, keep the top line locked in place. How can I do this with less?
2
votes
1answer
139 views
Monitoring file reads for cache warming
After adding more memory to my Linux machine I was tempted to use the cache more agressively.
The thing is: I boot up my machine, go to bathroom, come back and log in. It takes like half a minute to ...
1
vote
1answer
43 views
Reading data from serial port
FYI I am running busybox. I am able to send data to my ttyS1 using the following command:
stty -F /dev/ttyS1 speed 115200 cs8 -cstopb -parenb -echo
echo -en 'data here' > /dev/ttyS1
But when I ...
1
vote
0answers
178 views
Max transfer size in SG_IO/SG_ATA_16
I need to pass a direct, raw ATA request to a hard drive (0x25, READ DMA EXT), to disobey max sector count (long story), and to bypass all possible OS caches, buffers, reorderings et al.
...
1
vote
0answers
709 views
High iowait while the throughput and IOPS are low
I'm new to programming & Linux.
After I finished my programs(do some IO), I found iowait is very high(~65%) while the throughput(~5M/s read + ~5M/s write) and IOPS(50~100 QPS) are low.
iostat -...
1
vote
0answers
98 views
evaluating dual blocking commands in a bash condition statement
I am attempting to write a loop that refreshes a terminal either 1. when the file(s) have been modified, or 2. When user input is detected second interval. I know how to do one at a time, like so:
...
1
vote
1answer
52 views
Python `read -n1 var`?
Is there a Python 3 module that allows to input a single character, without having to press Enter afterwards?
Like Bash's read -n1 var?
1
vote
0answers
278 views
Random write on DISK benchmark shows high read rate on iostat
I am running a random write benchmark directly on some disks (HDD & SDD) and I am getting some weird output data on the iostat monitor. Besides the usual write rate, there is a read rate that I ...
1
vote
3answers
675 views
Printing a line at a specified offset in a file
I have a file with 50 characters on each line and 50 lines. Each line of the file contains arbitrary letters. I want to specify a character sequence number (ex: 52) and have the appropriate line of ...
1
vote
0answers
130 views
Responding to prompts automatically?
Lets say I have a script called RPS that simulates rock paper scissors.
For example lets say I run the script with "$sh RPS".
The script will echo "paper" and then prompt me for an input. Obviously ...
0
votes
0answers
35 views
Read numbers from a txt file as the variables, each time for each line
I just began learning to write c-shell scripts. (#! /bin/csh)
I have a txt file like this. (contain four parameters of three cases)
1 2 3 4
5 6 7 8
9 10 11 12
And I want to read this file each ...
0
votes
0answers
5 views
Sniffing to Signal Coming From a Controller to Raspberry Pi
I am working on a project on Raspberry Pi to send commands to a controller. I am using ttyUSB0 port of the Rpi with RS485 to communicate with controller. Normally, there is a dos program which does ...
0
votes
1answer
55 views
Filter script output during runtime
I have a script that runs about 10 other scripts in the background that constantly generate new output. I would like to keep that initial script running and be able to simply type in it to filter all ...
0
votes
0answers
39 views
How to create program that automatically removes old lines
Say I have a simple pipeline:
receive-data | write-to-file --max-lines 500 -f <file>
how can I implement a program write-to-file where the max number of lines is 500 or some number? (It can ...
0
votes
0answers
45 views
append to a string in loop not working
I have a ksh script, where I am trying to read from file in a loop and append certain values to each line in the file. It is not working.
Below is the code:
Code snippet:
input="$...
0
votes
2answers
668 views
How to read stderr from the process running in the background?
I wanna send the daemon into the background and only continue my script execution when the daemon outputs the particular line to the stderr, something among the lines:
# Fictional daemon
{
for x ...
0
votes
0answers
118 views
Alternative to `while read line` for pipe
I have this:
export var=1
kbc get pods -o=json | jq -r '.items[].metadata.name' | while read line; do
echo "$line";
done;
kbc get pods -o=json | jq -r '.items[].metadata.name' | xargs echo var=$...
0
votes
1answer
67 views
while read loop seems to terminate after the first line, when using two pipes?
#!/usr/bin/env bash
set -euo pipefail
while read -r line
do
echo "line via echo:"
echo "$line"
echo "line via sed:"
sed 's/w/f/g' | sed 's/f/zzzzz/g' <<< "$line"
done < /dev/...
0
votes
1answer
88 views
How to read only the last line of a live input stream in a while read loop
I have a very simple bash script that synchronizes data to a USB key as soon as new files appear. It is poorly written but it works, however I want to minimize CPU time so I used sleep but since I use ...
0
votes
1answer
506 views
Why does bash 'read' exit with status 1?
From an answer to "Bash script doesn't see SIGHUP?", I've got the following in my script:
while true; do read; done
And, usually, this works fine. However, when run from (tl;dr) ... something else, ...
0
votes
0answers
25 views
Reading existing screen displayed values
Using BASH, is there a way to capture characters that on currently on the screen?
More specifically, I need to display a screen, with what is currently in a variable, and allow the user to cursor ...
0
votes
0answers
97 views
What is the difference between nfs_readpage and nfs_read?
Does every nfs_read always has a nfs_readpage request or does both are exclusive? Please explain.
I am trying to understand this: http://www.fsl.cs.stonybrook.edu/~mchen/mountstat-format.txt
0
votes
1answer
75 views
read 1 or several lines in bash - make it work when pasting (in addition to typing manually)
I read multiple answers with varying complexities. Most are working well when the input is typed manually.
For example: https://stackoverflow.com/a/20913871/1841533 .
Here is my sample code, very ...
0
votes
1answer
43 views
How to backup /user/home with some requirements?
I'm currently studying scripting and I need to create an script to back up the /user/home using .bz2 compression. My teacher wants the person running the script to select the user to backup and the ...
0
votes
1answer
128 views
Cannot get interface information using read
The following link has a script to get system information:
z3bra' blog
Specifically,
network() {
read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
if iwconfig $...
0
votes
0answers
156 views
reading dates from process substitution using awk. Issue with field separator, splitting tokens incorrectly
I have the following code, thanks to @Janis for the help with the process substitution.
Also, apologies for creating a new question, I haven't received any recent replies on the thread of my previous ...
-1
votes
1answer
433 views
How to Interactively ask a user to change Permissions for a Specified File
I need to create a script that will allow a specified file to have its permissions changed interactively by asking the user if they would like to enable Read, Write and/or Execute one by one for each ...