Quantcast
Channel: Bash: How to read one line at a time from output of a command? - Unix & Linux Stack Exchange
Browsing all 6 articles
Browse latest View live

Answer by plhn for Bash: How to read one line at a time from output of a...

A small modification of Stéphane Chazelas's answer.find . -type f -exec bash -c 'echo $0; head $0;' {} \;This shows how the script you give to bash -c takes the first argument.

View Article


Answer by ᄂᄀ for Bash: How to read one line at a time from output of a command?

Remember that invoking commands has a cost (irrespective of what they do). This can have very negative impact on performance if you put them into a loop that will have multiple iterations. In case you...

View Article

Answer by ᄂᄀ for Bash: How to read one line at a time from output of a command?

There's no need for command substitution if you want to use pipe. read reads from stdin by default, so you just pipe into it:find . -type f -print0 |while read -r -d '' linedo echo "$line"doneor in one...

View Article

Answer by Stéphane Chazelas for Bash: How to read one line at a time from...

Note that there's nothing stopping file names from containing newline characters. The canonical way to run a command for each file found by find is.find . -type f -exec cmd {} \;And if you want things...

View Article

Answer by Gilles Quénot for Bash: How to read one line at a time from output...

There's a mistake, you need < <(command) not <<<$(command)< <( ) is a Process Substitution, $() is a command substitution and <<< is a here-string.

View Article


Bash: How to read one line at a time from output of a command?

I am trying to read the output of a command in bash using a while loop.while read -r linedo echo "$line"done <<< $(find . -type f)The output I got ranveer@ranveer:~/tmp$ bash test.sh./test.py...

View Article
Browsing all 6 articles
Browse latest View live




<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>