Skip to main content

Questions tagged [read]

`read` is a shell utility used for reading strings from the standard input stream, or from a file descriptor.

-2 votes
1 answer
99 views

Linux Bash Script - Yes or No - read answer

little script #!/bin/sh cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 4 printf 'do you like this? (y/n)? ' read answer if [ "$answer" != "${answer#[Yy]}" ] ;then ...
user447274's user avatar
-2 votes
1 answer
76 views

Is it possible to read user input with no extra variables?

I want to grep an IP address inside Nginx configuration files. I want to input the IP address with the read command, but I don't want to store input in an additional variable. So I want something like:...
palmasd1's user avatar
  • 125
0 votes
1 answer
31 views

Add a numerical value to a variable while reading a file in bash in loop [duplicate]

I have a file with the following values. I am trying to read from the file and add 1096 to the last value and generate the output on screen. My original file looks like this. agile_prod_toolkit,30 ...
ranjit abraham's user avatar
1 vote
2 answers
82 views

Is it possible to read from stderr in a bash script?

I have a bash script like this: #!/bin/bash while read -r -a line do ... parse $line in some way done This script is executed by piping the command from another program: some-random-program | ...
lord_nimon's user avatar
0 votes
1 answer
75 views

Find - xargs, for every line open a new shell and execute a command and wait for user to exit that shell

Following works Task: List all folders that contain file of iname *AlbumArt* that also contain iname *cover*.jpg, and for each of those folder list all jpg files with size find . -type f -iname '*...
Porcupine's user avatar
  • 2,056
0 votes
1 answer
33 views

Double backslash disappears when printed in a loop

I have a script that joins together various lists of data fields which then needs to have a few more columns added. The file generated looks like this: $ cat compiled.csv "name":"...
vxla's user avatar
  • 11
1 vote
1 answer
59 views

Unable to read more than 1024 chars on ZSH + MacOS

Trying to read a long input into a variable from ZSH on MacOS. echo "URL: " read URL input is always truncated to 1024 chars... if I try and type additional chars nothing happens. ...
SoonGuy's user avatar
  • 131
0 votes
1 answer
66 views

Issue of read with -u and -k in zsh

I am developing a zsh script that uses read -k. If I execute my script like this (echo a | myscript), it fails to get input. Apparently it is due to the fact that -k uses /dev/tty as stdin invariably, ...
Whimusical's user avatar
2 votes
3 answers
865 views

Execute copy commands from file

I have a DE_CopyOldToNew.txt file with a whole bunch of copy commands for copying old file names to new file names. The file contains rows like : cp /migrationfiles/Company\ Name\ GmbH/2014.138_Old\ ...
Rico Strydom's user avatar
0 votes
0 answers
158 views

read single line from stdin and write to a file

Is there a way in bash to read a single line from stdin and write directly to a file? Something like: t="$(mktemp)" while true do [read single line from stdin] > "${t}" [...
fuumind's user avatar
  • 449
1 vote
2 answers
120 views

How do I use a nonstandard file descriptor for reading a file into an array with mapfile?

mapfile -t -u 7 arr < textfile gives me bash: mapfile: 7: invalid file descriptor: Bad file descriptor Other, more verbose, methods of reading files line-by-line do allow for such descriptor, e.g. ...
John Smith's user avatar
2 votes
1 answer
490 views

Why does `read` fail saying "read error: 0: Resource temporarily unavailable"?

script #!/bin/bash -- # record from microphone rec --channels 1 /tmp/rec.sox trim 0.9 band 4k noiseprof /tmp/noiseprof && # convert to mp3 sox /tmp/rec.sox --compression 0.01 /tmp/rec.mp3 ...
Pound Hash's user avatar
2 votes
2 answers
617 views

pipe the read command?

I'm trying to pipe a string with special characters (e.g. HG@eg3,l'{TT\"C! to another command (termux-clipboard-set) with the read program. It seems that read was designed to create a temporary ...
Daniel Krajnik's user avatar
0 votes
2 answers
98 views

How to catch newlines in user input

I want to do something with user input to use in grep. Like, instead of uin="first\nsecond\n" printf $uin | grep d which outputs second, I want to have the user input it, like read uin ...
user14094230's user avatar
0 votes
0 answers
50 views

Circular pipe situation

More of an academic/theory question - say I have process A piping into process B: A | B normally, the way pipes are designed, is if process A dies, the pipeline will gracefully shutdown. However, if ...
Alexander Mills's user avatar

15 30 50 per page
1
2 3 4 5
25