You are truncating the file each time so you only get the last line. You probably want >>
instead of >
.
Shell Scripting: read input from command output
-
11-06-2023 - |
Domanda
Why does the following code gives only first line from ps -eaf output in ps.out?
while read line;
do
echo $line>ps.out;
done < <(/bin/ps -eaf)
Soluzione
Altri suggerimenti
Or redirect the entire loop output by putting ">ps.out" after the "done".
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow