Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Aug 2017 14:25:42 +0200
From:      Ralf Mardorf <ralf.mardorf@rocketmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Wildcard on redirection
Message-ID:  <20170805142542.499f4cee@archlinux.localdomain>
In-Reply-To: <20170805141306.60e720f5@archlinux.localdomain>
References:  <25f022f4-4778-3f28-8d78-1f1b292f849e@cloudzeeland.nl> <20170805141306.60e720f5@archlinux.localdomain>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 5 Aug 2017 14:13:06 +0200, Ralf Mardorf wrote:
>On Sat, 5 Aug 2017 13:58:50 +0200, Jos Chrispijn wrote:
>>I have this number of .log files which I would like to empty.
>>
>>Using
>>
>>echo > *.log
>>
>>unfortunately doesn't work so I created
>>
>>foreach file in (/myfiles/log/*log)
>>   echo "" > $file
>>end
>>
>>but that sequence is not recognized at all.
>>
>>Can you tell me how to solve? Thanks!  
>
>I suspect the dot isn't useful at all, I guess with or without the dot
>"analog" would be "*log", too, but actually your shell might treat the
>dot in a different way.
>
>However
>
>echo "" | tee *log
>
>does the trick.
>
>https://www.freebsd.org/cgi/man.cgi?query=tee&sektion=1&apropos=0&manpath=redhat

Oops, I'm at least mistaken for bash, but you unlikely use bash, right?

$ cd /tmp/
$ echo "12342" > 1.log; echo "1234" > analog
$ cat *log
12342
1234
$ cat *.log
12342
$ echo "" | tee *.log

$ cat *.log

$ cat *log

1234

so the dot makes a difference. I was confusing it with the dot at
the beginning of a file and the asterisk as wildcard in front of the
dot or without the dot, when using "ls" in bash.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170805142542.499f4cee>