Linked Questions

6 votes
3 answers
4k views

The command df . can show us which device we are on. For example, me@ubuntu1804:~$ df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb1 61664044 8510340 49991644 15% /home ...
Yves's user avatar
  • 3,411
4 votes
2 answers
10k views

I have a global variable $EMAIL. I want to loop through several files and for each that meets a criteria I will add it to $EMAIL for report generation. The problem is when I redefine $EMAIL inside ...
Philip Kirkbride's user avatar
2 votes
1 answer
7k views

I'm trying to pipe a command's output to the read builtin of my shell and I get a different behaviour for zsh and bash: $ bash -c 'echo hello | read test; echo $test' $ zsh -c 'echo hello | read ...
Doron Behar's user avatar
0 votes
1 answer
11k views

I have some environment variables declared in a YAML file like: runtime: python37 env_variables: API_URL: 'https://fake.api.com/' API_USERNAME: '[email protected]' API_PASSWORD: 'Passwooord' I ...
neurino's user avatar
  • 1,839
4 votes
1 answer
3k views

bash builtin command read is said to accept input from stdin, but why does the following not read in anything? $ printf "%s" "a b" | read line $ printf "%s" "$line" $ Thanks.
Tim's user avatar
  • 107k
1 vote
1 answer
1k views

read command in sh works if I redirect file1 as standard input like $ cat file1 first second $ read u v <file1 $ echo $u first $ echo $v second However, if I redirect standard output from echo ...
wkde's user avatar
  • 125
1 vote
1 answer
815 views

With regard to the below commands: $ unset a $ echo 12 | read a $ echo $a $ I was expecting that a would be set the value of 12 in the second statement. But it turns out that a is still unset.
user15740's user avatar
  • 123
0 votes
1 answer
367 views

From the bash man page for the read command: One line is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, split into words as described above ...
user1934428's user avatar
0 votes
0 answers
1k views

First of all, I have little experience using Bash and I apologize for my bad English. Maybe it's obvious. I am trying to understand why Bash drop value of the variable in this oneliner. echo "...
bas1c's user avatar
  • 1
-1 votes
1 answer
232 views

I quite don't understand why Bash would not hold the value of myvar in this example. echo hello | read myvar && echo $myvar I would understand if I were running that command as two separate ...
Daniel N.'s user avatar
  • 111
0 votes
0 answers
236 views

I'm having trouble assigning values to a specific bash index, but apparently only when the index variable is set using a while read loop. Taking this code as a test example: #!/bin/bash read -d '' ...
steinocaro's user avatar
1 vote
1 answer
73 views

My code var=34 find $1 -type f | while read line; do file_status=`file "$line"` file_name=`echo $line | sed s/".*\/"//g` line_length=${#file_name} if [ $line_length -...
user1452079's user avatar
1 vote
0 answers
34 views

I'm having difficulties understanding the following example I created. The variable glob_var gets changed inside the test() function, but the original value remains outside of the function: test() { ...
Subbeh's user avatar
  • 430
0 votes
0 answers
37 views

why does a echo | read behave differently to echo | while read? $ echo -e "1\t2\t3" | read a b c; echo "$a-$b-$c" -- $ echo -e "1\t2\t3" | while read a b c; do echo &...
ciis0's user avatar
  • 131
1 vote
0 answers
22 views

I thought that piping from echo was equivalent to here strings, but the REPLY variable of the read builtin command is only set (or in scope I guess) when using here strings: echo foo | read;echo $...
Johannes Riecken's user avatar

15 30 50 per page