watch with piped command executes differently than command itself
0
votes
1
answer
49
views
What am I doing wrong setting up following watch command? This works:
ls -ltr ~/meteofetcher/data/metar/2024/12 | tail -10 | awk '{ print $9 }' | xargs -I {} grep 'LSZH' {}
But this
watch "ls -ltr ~/meteofetcher/data/metar/2024/12 | tail -10 | awk '{ print $9 }' | xargs -I {} grep 'LSZH' {}"
only lets me watch the following error:
Every 2.0s: ls -ltr ~... : Fri Dec 20 06:27:05 2024
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
It's probably something to do with the quotation but I tried to do t he same with single quotes outside and double quotes inside and it still doesn't work.
This produces the same error (and it shouldn't expand the $ afaik)
watch 'ls -ltr ~/meteofetcher/data/metar/2024/12 | tail -10 | awk "{ print $9 }" | xargs -I {} grep "LSZH" {}'
Where did I go wrong?
Asked by glades
(117 rep)
Dec 20, 2024, 06:26 AM
Last activity: Dec 20, 2024, 09:27 AM
Last activity: Dec 20, 2024, 09:27 AM