Tagged Questions
7
votes
3answers
155 views
How to properly collect an array of lines in zsh
I thought the following would group the output of my_command in an array of lines:
IFS='\n' array_of_lines=$(my_command);
so that $array_of_lines[1] would refer to the first line in the output of ...
3
votes
4answers
595 views
How can I detect if the shell is controlled from SSH?
I want to detect from a shell script (more specifically .zshrc) if it is controlled through SSH. I tried the HOST variable but it's always the name of the computer which is running the shell. Can I ...
1
vote
2answers
141 views
Why doesn't the following work?: while true; do “$my_command”; sleep 1; done
Following up on the top answer to this question, I thought I could:
1) Define a command:
cmd='for x in $(my_command | grep keyword | cut -d" " -f1); do command2 "arguments" $x; done'
2) Run it ...