case command

Ralf Mardorf ralf.mardorf at rocketmail.com
Sun Sep 17 20:22:47 UTC 2017


On Sun, 17 Sep 2017 19:40:20 +0200, Polytropon wrote:
>% grep "catfood" < food.txt > mister_kitty.txt

Regarding https://www.freebsd.org/cgi/man.cgi?query=grep&sektion=&n=1
it should work without the "<" the same way it does on Linux [1].

As already pointed out, the inequality signs/angle brackets cause issues
when sudo is required.

[1]
$ ls -hl bar.txt 
-r-------- 1 root root 4 Sep 17 19:49 bar.txt
$ sudo grep "foo" < bar.txt > out-file.txt 
bash: bar.txt: Permission denied
$ sudo grep "foo" bar.txt > out-file.txt 
$ cat out-file.txt 
foo
$ sudo grep "foo" bar.txt | sudo tee out-file-2.txt 
foo
$ ls -hl out-file*txt
-rw-r--r-- 1 root        root        4 Sep 17 20:00 out-file-2.txt
-rw-r--r-- 1 rocketmouse rocketmouse 4 Sep 17 19:58 out-file.txt

.


More information about the freebsd-questions mailing list