[opensuse] some bash hints, please
I am looking for some bash scripts: 1. I want to list all text files of one directory with a blank line in between. Currently I just use grep "" * 2. I want to delete files older than x (e.g., 3 minutes, 3 hours, 3 days, ...) bye Ronald -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Dne Monday 05 November 2007 08:03:18 Ronald Wiplinger napsal(a): > I am looking for some bash scripts: > > 1. I want to list all text files of one directory with a blank line in > between. > Currently I just use grep "" * Text files? You mean file.txt, or file with text mime type? 100+1 how to do this. - ls *.txt - find . -name "*.txt" if you need use mime types try ls | xargs file {} | grep text > 2. I want to delete files older than x (e.g., 3 minutes, 3 hours, 3 > days, ...) man find, look for TESTS or somethink like ls -l | awk ' if($6>"2007-11-06") {print $0}' > > bye > > Ronald -- Pavel Nemec Software Engineer --------------------------------------------------------------------- SuSE CR, s.r.o. e-mail: pnemec@suse.cz Lihovarska 1060/12 tel:+420 284 028 981 190 00 Praha 9 fax:+420 296 542 374 Ceska republika http://www.suse.cz ---------------------------------------------------------------------
Pavel Nemec wrote: > Dne Monday 05 November 2007 08:03:18 Ronald Wiplinger napsal(a): >> I am looking for some bash scripts: >> >> 1. I want to list all text files of one directory with a blank line in >> between. >> Currently I just use grep "" * > Text files? You mean file.txt, or file with text mime type? > 100+1 how to do this. > - ls *.txt > - find . -name "*.txt" > > if you need use mime types > try > ls | xargs file {} | grep text > >> 2. I want to delete files older than x (e.g., 3 minutes, 3 hours, 3 >> days, ...) > man find, look for TESTS > > or somethink like > ls -l | awk ' if($6>"2007-11-06") {print $0}' find using the -mtime and the -exec option is more appropriate. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Mon November 5 2007 00:03, Ronald Wiplinger wrote:
I am looking for some bash scripts:
1. I want to list all text files of one directory with a blank line in between. Currently I just use grep "" *
You are listing the content of the files with this command and I don't get a blank line in between. When I want to list the content of ASCII files with the filename preceding each, I use more * > tmp.txt
2. I want to delete files older than x (e.g., 3 minutes, 3 hours, 3 days, ...)
For x in days: find . -mtime +x -print -exec \rm -f '{}' \; For x in minutes change -mtime to -mmin . -- Carlos FL Who is General Failure, and why is he reading my disk? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Mon, 05 Nov 2007, by ronald@elmit.com:
I am looking for some bash scripts:
1. I want to list all text files of one directory with a blank line in between. Currently I just use grep "" *
for i in $(find ./ -maxdepth 1 -type f);do file $i| grep ASCII test $? -eq 0 && echo done
2. I want to delete files older than x (e.g., 3 minutes, 3 hours, 3 days, ...)
The creation time or date is not kept in Unix, so there's no sure way of knowing how 'old' a file is, only when it was last accessed or modified. Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 26N , 4 29 47E. + ICQ: 277217131 SUSE 10.2 + Jabber: muadib@jabber.xs4all.nl Kernel 2.6.20 + See headers for PGP/GPG info. Claimer: any email I receive will become my property. Disclaimers do not apply. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (5)
-
Aaron Kulkis
-
Carlos F Lange
-
Pavel Nemec
-
Ronald Wiplinger
-
Theo v. Werkhoven