Shell Scripting: read input from command output

rahul

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)
cnicutar

You are truncating the file each time so you only get the last line. You probably want >> instead of >.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

python read from shell command output

From Dev

Shell output from one command as input to other

From Dev

Read output of shell command in meteor

From Dev

How to get output as Tabular Format from Shell scripting?

From Dev

Read Input From Command Line

From Dev

UNIX shell scripting if and grep command

From Dev

Command output to a file with batch scripting

From Dev

How to make an output limited to 'n' characters in shell scripting and also in command line

From Dev

Log all output from a shell command

From Dev

Log all output from a shell command

From Dev

How to capture output from bourne shell command

From Dev

Fish shell input redirection from subshell output

From Dev

Change PulseAudio Input/Output from Shell?

From Dev

Is there any way to read lines from command output?

From Dev

Execute Shell Command, and read it's output in Chrome Packaged Apps

From Dev

how to read multiline output command line by line, in a shell script?

From Dev

Execute Shell Command, and read it's output in Chrome Packaged Apps

From Dev

Making paste command read from standard input

From Dev

read command is not taking input from the terminal

From Dev

Shell Scripting: Store loop output in separate array

From Dev

grep ifconfig output using shell scripting

From Dev

Shell Scripting: Convert file string to be usable in a command

From Dev

Unix Shell scripting in AIX(Sed command)

From Dev

Search multiple strings from file in multiple files in specific column and output the count in unix shell scripting

From Dev

Shell scripting : Change in input stream not working as desired

From Dev

(Shell Scripting) - Modify files with user input

From Dev

What does it mean to read from standard input and output to standard output?

From Dev

output Command Shell in if statment

From Dev

Bash scripting and large files (bug): input with the read builtin from a redirection gives unexpected result

Related Related

  1. 1

    python read from shell command output

  2. 2

    Shell output from one command as input to other

  3. 3

    Read output of shell command in meteor

  4. 4

    How to get output as Tabular Format from Shell scripting?

  5. 5

    Read Input From Command Line

  6. 6

    UNIX shell scripting if and grep command

  7. 7

    Command output to a file with batch scripting

  8. 8

    How to make an output limited to 'n' characters in shell scripting and also in command line

  9. 9

    Log all output from a shell command

  10. 10

    Log all output from a shell command

  11. 11

    How to capture output from bourne shell command

  12. 12

    Fish shell input redirection from subshell output

  13. 13

    Change PulseAudio Input/Output from Shell?

  14. 14

    Is there any way to read lines from command output?

  15. 15

    Execute Shell Command, and read it's output in Chrome Packaged Apps

  16. 16

    how to read multiline output command line by line, in a shell script?

  17. 17

    Execute Shell Command, and read it's output in Chrome Packaged Apps

  18. 18

    Making paste command read from standard input

  19. 19

    read command is not taking input from the terminal

  20. 20

    Shell Scripting: Store loop output in separate array

  21. 21

    grep ifconfig output using shell scripting

  22. 22

    Shell Scripting: Convert file string to be usable in a command

  23. 23

    Unix Shell scripting in AIX(Sed command)

  24. 24

    Search multiple strings from file in multiple files in specific column and output the count in unix shell scripting

  25. 25

    Shell scripting : Change in input stream not working as desired

  26. 26

    (Shell Scripting) - Modify files with user input

  27. 27

    What does it mean to read from standard input and output to standard output?

  28. 28

    output Command Shell in if statment

  29. 29

    Bash scripting and large files (bug): input with the read builtin from a redirection gives unexpected result

HotTag

Archive