shell script
Jonathan Billings
jsbillin at Princeton.EDU
Wed Jul 18 11:58:40 UTC 2007
On Tue, Jul 17, 2007 at 07:19:36PM +0530, Mahalingam Subramaniam wrote:
> Dear All
>
> My Query is as follows:
>
> I have extracted the output and details of mail users mail inbox size with
> file path name.
>
> 140K /abcde/fghij/w001/wesley
> 26M /mnopq/rstuvwx/w001/wilson
> 1G /mnopq/rstuvwx/w001/alok
> 2G /mnopq/rstuvwx/w001/john
>
> Here, I want to extract and paste the output of only users whose inbox
> size is 1GB or more than 1GB using shell script "cat"
> (e.g.) cat mailstorage.txt (source file containing all users mail inbox
> size information) |awk -F ' ' '{print...... >> gboutput.txt (target file
> to paste the final output) similar to this.
I'd probably use perl, since it can save you some effort
perl -nale 'print((split("/",$F[1]))[-1]) if $F[0]=~/^\d+G/' mailstorage.txt
(If you'd like me to explain what I'm doing, let me know. I realize
some people think perl resembles line noise.)
Also, I'd like to note, typing 'cat file.txt | awk ...' or 'cat
file.txt | grep ...' generates a useless pipe. Just pass the file as
an argument to awk or grep, they can handle the file I/O. This can
save a lot of memory and time if you are working with very large
files.
--
Jonathan Billings <jsbillin at princeton.edu>
Computational Science and Engineering Support (CSES)
http://www.princeton.edu/~cses/
More information about the redhat-sysadmin-list
mailing list