Hi,
I have a log file contain 28 lines,
1-I need to grep the line with the size next to that i need to grep the name from the line
Example:
Size element
1. 906K ykms2
2. 1.2M ykps1
2-if one or more of the lines are missing I need to have that printed
Example:
There are 26 file in the directory the missing files are:
1.ykas4
2.hfns1
3-I need to find out if the size of the files is smaller than the size seen below,
Example:
1.The size of the file from ykms2 is less that 906K
2.The size of the file from ykps1 is less that 1.2M

At the end I need all of the info to be printed to a log file.

Thanks in advance,
Erez

Here are the 28 lines:

-rw-r--r-- 1 101 102 906K Jul 5 02:30 2012187014201-20120705-13907-MS_Rel_17.sp2_1.88-ykms2-1fac1fae.tar.gz
-rw-r--r-- 1 101 102 1.2M Jul 5 02:30 2012187013702-20120705-20272-PS_Rel_17.sp2_1.88-ykps1-1fac19ae.tar.gz
-rw-r--r-- 1 101 102 946K Jul 5 02:30 2012187013201-20120705-11904-MS_Rel_17.sp2_1.88-ykms1-1fac1eae.tar.gz
-rw-r--r-- 1 101 102 25M Jul 5 02:30 2012187011702-20120705-18520-NS_Rel_17.sp1_1.316-ykns1-1fac14ae.tar.gz
-rw-r--r-- 1 101 102 156M Jul 5 02:30 2012187011601-20120705-11608-AS_Rel_17.sp2_1.88-ykas4-1fac05ae.tar.gz
-rw-r--r-- 1 101 102 159M Jul 5 02:30 2012187011202-20120705-25902-AS_Rel_17.sp2_1.88-ykas3-1fac04ae.tar.gz
-rw-r--r-- 1 101 102 160M Jul 5 02:30 2012187010801-20120705-642-AS_Rel_17.sp2_1.88-ykas2-1fac03ae.tar.gz
-rw-r--r-- 1 101 102 303M Jul 5 02:30 2012187010201-20120705-12683-XSP_Rel_17.sp2_1.88-ykxspprov1-1fac3cae.tar.gz
-rw-r--r-- 1 101 102 303M Jul 5 02:30 2012187014201-20120705-26189-XSP_Rel_17.sp2_1.88-ykxsp2-1fac83ae.tar.gz
-rw-r--r-- 1 101 102 26M Jul 5 02:40 2012187012301-20120705-10767-NS_Rel_17.sp1_1.316-hfns1-1fac14e2.tar.gz
-rw-r--r-- 1 101 102 173M Jul 5 02:40 2012187010402-20120705-15021-AS_Rel_17.sp2_1.88-ykas1-1fac02ae.tar.gz
-rw-r--r-- 1 101 102 158M Jul 5 02:41 2012187012301-20120705-24809-AS_Rel_17.sp2_1.88-hfas2-1fac03e2.tar.gz
-rw-r--r-- 1 101 102 170M Jul 5 02:41 2012187011901-20120705-27946-AS_Rel_17.sp2_1.88-hfas1-1fac02e2.tar.gz
-rw-r--r-- 1 101 102 156M Jul 5 02:41 2012187013201-20120705-4493-AS_Rel_17.sp2_1.88-hfas4-1fac05e2.tar.gz
-rw-r--r-- 1 101 102 157M Jul 5 02:41 2012187012702-20120705-20072-AS_Rel_17.sp2_1.88-hfas3-1fac04e2.tar.gz
-rw-r--r-- 1 101 102 303M Jul 5 02:42 2012187013201-20120705-9659-XSP_Rel_17.sp2_1.88-hfxsp1-1fac82e2.tar.gz
-rw-r--r-- 1 101 102 303M Jul 5 02:42 2012187011202-20120705-29856-XSP_Rel_17.sp2_1.88-hfxspprov1-1fac3ce2.tar.gz
-rw-r--r-- 1 101 102 303M Jul 5 02:45 2012187012202-20120705-4906-XSP_Rel_17.sp2_1.88-ykxsp1-1fac82ae.tar.gz
-rw-r--r-- 1 101 102 900K Jul 5 02:50 2012187013601-20120705-26512-MS_Rel_17.sp2_1.88-hfms1-1fac1ee2.tar.gz
-rw-r--r-- 1 101 102 52M Jul 5 03:00 2012187013401-20120705-23502-EMS_Rel_17.sp1_1.316-ykems1-1fac4bae.tar.gz
-rw-r--r-- 1 101 102 52M Jul 5 03:19 2012187014301-20120705-19418-EMS_Rel_17.sp1_1.316-hfems1-1fac4be2.tar.gz
-rw-r--r-- 1 101 102 746K Jul 5 03:19 2012187014601-20120705-32723-MS_Rel_17.sp2_1.88-hfms2-1fac1fe2.tar.gz
-rw-r--r-- 1 101 102 18M Jul 5 03:19 2012187014701-20120705-31649-CDS_Rel_17.0_1.458-ykcds1-1fac41ae.tar.gz
-rw-r--r-- 1 101 102 13M Jul 5 03:19 2012187014902-20120705-27766-CDS_Rel_17.0_1.458-hfcds1-1fac41e2.tar.gz
-rw-r--r-- 1 101 102 892K Jul 5 03:19 2012187015201-20120705-21743-MS_Rel_17.sp2_1.88-ykms3-1fac20ae.tar.gz
-rw-r--r-- 1 101 102 303M Jul 5 03:21 2012187015201-20120705-406-XSP_Rel_17.sp2_1.88-hfxsp2-1fac83e2.tar.gz
-rw-r--r-- 1 101 102 800K Jul 5 03:21 2012187015602-20120705-6037-MS_Rel_17.sp2_1.88-hfms3-1fac20e2.tar.gz
-rw-r--r-- 1 101 102 1.2M Jul 5 03:21 2012187015701-20120705-5567-PS_Rel_17.sp2_1.88-hfps1-1fac19e2.tar.gz

Recommended Answers

All 4 Replies

hi,

are you sure you need all these informations in the file list?
wouldn't you use stat to keep only useful informations, instead of ls -nh?

Hi,
stat will not help because I don't need the info of the files in the directory,
I need to grep the info from a text file contain the print out of ls-ltrh from a directory.

again, do you really need all these informations in the file?
if you can't use stat, maybe ls -srth could be enough...

after what you use a while loop to read the listing file by redirecting its content to the loop.

Solved,
Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.