kin
1
I would like to empty multiple files contents (without delete the file) which have similar name to begin with.
e.g.
log1.txt
log2.txt
log3.txt
log4.txt
I know cat /dev/null will do the job but that only apply to a single file. But when i tried cat /dev/null > {} \; that doesnt do anything at all.
try this thing;
find . -type f -name '*.txt' -print | while read i
do
echo " " > $i
done
this will clear out the content of every *.txt found in "." (current directory)
It is not totally clear but a space I think...
hope it help..(smiley)
1 Like
for i in log*.txt
do
cat /dev/null >"$i"
done
1 Like
Zero works aswell
.... whateva loop ..
0>$i
.....
1 Like
Nothing works as well
.... whateva loop ..
>$i
.....
1 Like
echo log*.txt | xargs -n1 cp /dev/null
2 Likes
for i in log*.txt; do
printf "" > "$i"
done
1 Like
kin
8
Thanks Everyone !! It all works well