Skip to main content
Commonmark migration
Source Link

I recently learned about [watch][1]watch, but am having trouble making it work with relatively sophisticated commands.

For example, I would like to ask watch to run the following command on zsh every three seconds*:

for x in `command_1 | grep keyword | cut -d' ' -f1`; do command_2 "word[word=number]" $x; done 

as you can see the line above includes single quotes, double quotes, among other special characters.

So I tried:

watch -n 3 "for x in `my_command | grep keyword | cut -d' ' -f1`; do command2 "rusage[mem=7000]" $x; done" 

but then I got:

no matches found for x in !@#$# ....; done

I tried other combinations without success. Here's one of those attempts:

watch -n 3 "for x in $(bjobs -w | grep pre_seg | cut -d' ' -f1); do bmod -R "rusage[mem=7000]" $x; done" 

which also results in a similar error.

Any ideas how to make this work?


*I would also be intersted in solutions that work on bash [1]: http://en.wikipedia.org/wiki/Watch_%28Unix%29

I recently learned about [watch][1], but am having trouble making it work with relatively sophisticated commands.

For example, I would like to ask watch to run the following command on zsh every three seconds*:

for x in `command_1 | grep keyword | cut -d' ' -f1`; do command_2 "word[word=number]" $x; done 

as you can see the line above includes single quotes, double quotes, among other special characters.

So I tried:

watch -n 3 "for x in `my_command | grep keyword | cut -d' ' -f1`; do command2 "rusage[mem=7000]" $x; done" 

but then I got:

no matches found for x in !@#$# ....; done

I tried other combinations without success. Here's one of those attempts:

watch -n 3 "for x in $(bjobs -w | grep pre_seg | cut -d' ' -f1); do bmod -R "rusage[mem=7000]" $x; done" 

which also results in a similar error.

Any ideas how to make this work?


*I would also be intersted in solutions that work on bash [1]: http://en.wikipedia.org/wiki/Watch_%28Unix%29

I recently learned about watch, but am having trouble making it work with relatively sophisticated commands.

For example, I would like to ask watch to run the following command on zsh every three seconds*:

for x in `command_1 | grep keyword | cut -d' ' -f1`; do command_2 "word[word=number]" $x; done 

as you can see the line above includes single quotes, double quotes, among other special characters.

So I tried:

watch -n 3 "for x in `my_command | grep keyword | cut -d' ' -f1`; do command2 "rusage[mem=7000]" $x; done" 

but then I got:

no matches found for x in !@#$# ....; done

I tried other combinations without success. Here's one of those attempts:

watch -n 3 "for x in $(bjobs -w | grep pre_seg | cut -d' ' -f1); do bmod -R "rusage[mem=7000]" $x; done" 

which also results in a similar error.

Any ideas how to make this work?


*I would also be intersted in solutions that work on bash

edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
added 147 characters in body
Source Link
Amelio Vazquez-Reina
  • 43.1k
  • 81
  • 211
  • 300

I recently learned about watch[watch][1], but am having trouble making it work with relatively sophisticated commands.

E.g. IFor example, I would like to ask watch to run the following command on zsh every three seconds*:

for x in `command_1 | grep keyword | cut -d' ' -f1`; do command_2 "word[word=number]" $x; done 

as you can see the line above includes single quotes, double quotes, among other thingsspecial characters.

So I tried:

watch -n 3 "for x in `my_command | grep keyword | cut -d' ' -f1`; do command2 "rusage[mem=7000]" $x; done" 

but then I got:

no matches found for x in !@#$# ....; done

I tried other combinations of single and double quotes without success. Here's one of those attempts:

watch -n 3 "for x in $(bjobs -w | grep pre_seg | cut -d' ' -f1); do bmod -R "rusage[mem=7000]" $x; done" 

which also results in a similar error.

Any ideas how to make this work?


*I would also be intersted in solutions that work on bash [1]: http://en.wikipedia.org/wiki/Watch_%28Unix%29

I recently learned about watch, but am having trouble making it work with relatively sophisticated commands.

E.g. I would like to ask watch to run the following command every three seconds:

for x in `command_1 | grep keyword | cut -d' ' -f1`; do command_2 "word[word=number]" $x; done 

as you can see the line above includes single quotes, double quotes, among other things.

So I tried:

watch -n 3 "for x in `my_command | grep keyword | cut -d' ' -f1`; do command2 "rusage[mem=7000]" $x; done" 

but then I got:

no matches found for x in !@#$# ....; done

I tried other combinations of single and double quotes without success.

Any ideas how to make this work?

I recently learned about [watch][1], but am having trouble making it work with relatively sophisticated commands.

For example, I would like to ask watch to run the following command on zsh every three seconds*:

for x in `command_1 | grep keyword | cut -d' ' -f1`; do command_2 "word[word=number]" $x; done 

as you can see the line above includes single quotes, double quotes, among other special characters.

So I tried:

watch -n 3 "for x in `my_command | grep keyword | cut -d' ' -f1`; do command2 "rusage[mem=7000]" $x; done" 

but then I got:

no matches found for x in !@#$# ....; done

I tried other combinations without success. Here's one of those attempts:

watch -n 3 "for x in $(bjobs -w | grep pre_seg | cut -d' ' -f1); do bmod -R "rusage[mem=7000]" $x; done" 

which also results in a similar error.

Any ideas how to make this work?


*I would also be intersted in solutions that work on bash [1]: http://en.wikipedia.org/wiki/Watch_%28Unix%29

Source Link
Amelio Vazquez-Reina
  • 43.1k
  • 81
  • 211
  • 300
Loading