Sponsored Content
Top Forums Shell Programming and Scripting Display file date after grepping a string in the file Post 302645499 by quemalr on Wednesday 23rd of May 2012 03:31:44 PM
Old 05-23-2012
Hi Neturon,

That is working, thanks so much. Some of the sub directories don't have .CSV files, this isn't a show stopper but if there is a way to ignore those directories names it would be nice. Again I really appreciate your help with this.

Q

Code:
-bash: :shopt: command not found
grep: ./*.csv????????: No such file or directory
grep: ./modemdata/*.csv????????: No such file or directory
grep: ./modemdata/clara1/*.csv????????: No such file or directory
grep: ./modemdata/duagh/*.csv????????: No such file or directory
grep: ./modemdata/crushum1/*.csv????????: No such file or directory
grep: ./modemdata/bweeng1/*.csv????????: No such file or directory
grep: ./modemdata/wmtn1/*.csv????????: No such file or directory

---------- Post updated at 02:31 PM ---------- Previous update was at 02:05 PM ----------

Hello Neutronscott,

I used your code as a function in my shell script and I'm sorted now. Thanks again for your great help.

Q.
Code:
Historical Data 
===============

Note CMTS name as modem may have been elsewhere.
Data is sorted by date. Continue (y/n)? y

12052222    ./Knock1    192.168.12.17,0:15:a3:5:f0:e8,256000000,24900000,-110,207,430,2570359452,902613,17,2570359452,902613,17
12052122    ./Knock1    192.168.12.17,0:15:a3:5:f0:e8,256000000,24900000,-105,212,420,1447627316,387299,17,1447705286,387332,17
12052022    ./Knock1    192.168.12.17,0:15:a3:5:f0:e8,256000000,24900000,-98,220,430,324776443,69203,0,324854437,69212,0
12051922    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-99,218,420,3657973345,728134,3,3657973345,728134,3
12051822    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-79,226,410,2534951716,504005,0,2534951716,504019,0
12051722    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-96,219,420,1411912195,297710,0,1411990190,297719,0
12051622    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-100,218,420,288944067,19916,0,289022068,19918,0
12051522    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-92,222,420,3862361193,2424643,16,3862361193,2424643,
12051422    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-97,214,420,2740329778,1210266,16,2740407725,1210322,16
12051322    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-98,218,400,1618342421,107815,16,1618420418,107821,16
12051222    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-92,224,420,495130594,73901,0,495130594,73901,0
12051122    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-92,221,420,1095892783,2766410,25506,1095970783,2766414,25506
12051022    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-101,216,420,4268415343,2199364,25504,4268415343,2199364,25504
12050822    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-78,228,420,2022490844,1763857,25490,2022490844,1763857,25490
12050722    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-95,223,420,899802157,1206732,25467,899880157,1206735,25467
12050622    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-73,233,400,4071727996,1164950,25467,4071727996,1164950,25467
12050522    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-75,228,410,2948504596,1142367,25467,2948582599,1142367,25467
12050422    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-76,229,410,1825349711,1129414,25467,1825349711,1129414,25467
12050322    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-95,222,400,702352670,958581,25467,702430672,958582,25467
12050222    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-95,221,400,3874410136,804757,25467,3874488135,804761,25467
12050122    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-76,229,400,2751352091,772715,25464,2751430094,772715,25464
12043022    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-76,231,410,1628112062,767048,25449,1628190065,767048,25449
12042922    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-74,229,390,505026077,763368,25449,505026077,763368,25449
12042822    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-71,231,390,3676672618,760438,25449,3676672618,760438,25449
12042722    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,236,400,2553508591,756755,25449,2553508591,756755,25449
12042622    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,237,390,1430342827,,25449,1430342827,754842,25449
12042522    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,235,390,307355087,748087,25449,307433091,748087,25449
12042422    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-73,230,400,3479079570,745253,25449,,745253,25449
12042322    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-71,,400,2355998680,736282,25444,2355998680,736282,25444
12042222    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-70,233,410,1232761331,727833,25444,1232839333,727833,25444
12042122    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-71,231,400,109520177,723218,25444,109598180,723218,25444
12042022    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-72,233,,3281401739,719189,25444,3281479742,719189,25444
12041922    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,236,,2158235649,717457,25444,2158313652,717457,25444
12041822    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,234,390,1035214531,714665,25440,1035292534,714665,25440
12041722    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-91,226,390,4207018603,710075,25440,4207018603,710075,25440
12041622    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-90,224,400,3083858451,702531,25440,3083936454,702532,25440
12041522    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,235,410,1960696063,696864,25437,1960696063,696864,25437
12041422    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,,229,390,837451147,696017,25437,837451147,696017,25437
12041322    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,238,400,4009095573,695175,25437,4009173576,695175,25437
12041222    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-68,240,400,2886322256,690714,25433,2886322256,690714,25433
12041122    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-68,239,400,1762843479,689656,25433,1762843479,689656,25433
12041022    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,,-69,240,400,639598897,688342,25433,639676900,688342,25433
12040922    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-68,239,390,3811554991,687794,25433,3811632994,687794,25433
12040822    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-72,235,390,2688389489,685563,25433,2688467492,685563,25433
12040722    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-72,232,390,1565066602,684596,25433,1565144605,684596,
12040622    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-74,230,390,441977600,683653,25433,442055604,683653,25433
12040522    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-61,239,390,3613888866,651768,70,3613966869,651768,70
12040422    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-70,244,380,2490559867,651531,70,2490637871,651531,70
12040322    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,245,380,1367476506,645091,70,1367476506,,70
12040222    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-69,235,390,244232014,643844,70,244310017,643844,70
12040122    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-71,234,390,3416042062,633303,70,3416042062,633303,70
12033122    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-72,234,400,2292799278,630250,68,2292877281,630250,68
12033022    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-75,232,390,1169633582,628207,0,1169633582,628207,0
12032922    ./Knock1    192.168.12.50,0:15:a3:5:f0:e8,256000000,24900000,-105,213,370,46397918,617997,0,46475887,618031,0
12032722    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,242,410,3336289051,27343,40,3336289051,27343,40
12032622    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-69,239,410,2213063032,6803,40,2213063032,6803,40
12032522    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-69,240,410,1089818042,5333,40,1089896045,5333,40
12032422    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-69,238,400,13690718,14,0,13768721,14,0
12032322    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-60,242,400,3415637568,6050,0,3415637568,6050,0
12032222    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,232,400,2292394283,3467,0,2292394283,3467,0
12032121    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-61,242,400,1158387238,252,0,1158465241,252,0
12032022    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-61,244,400,45828016,19,0,45828016,19,0
12031922    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-62,243,400,3677644715,22607,2,3677722718,22607,2
12031822    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,247,390,2554555283,22340,0,2554633286,22340,0
12031722    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,243,390,1431153789,22098,0,1431231792,22098,0
12031622    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-61,241,400,308127482,21888,0,308127482,21888,0
12031522    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,234,410,3480083125,21758,0,3480161129,21758,0
12031422    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,242,400,2356759356,21601,0,2356837359,21601,0
12031322    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,240,400,1233690604,437,0,1233768608,437,0
12031222    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-69,237,400,110570664,18,0,110570664,18,0
12031122    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,243,410,3814741423,14969,1628,,14969,1628
12031022    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-78,236,430,2691419760,12715,1628,2691497763,12715,1628
12030922    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,236,400,1569292225,2521,0,1569292225,2521,0
12030822    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,241,420,445501799,1120,0,445579803,1120,0
12030722    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,245,390,3617280809,623,0,3617358812,623,0
12030622    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-61,242,400,2494035230,492,0,2494113233,492,0
12030522    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-67,248,390,1370945708,259,0,1370945708,259,0
12030422    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-67,247,390,247778209,43,0,247778209,43,0
12030322    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,246,390,3721129720,5485,16,3721129720,5485,16
12030222    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-71,245,400,2598946725,3544,16,2599024728,3544,16
12030122    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-69,238,400,1475884403,3252,16,1475884403,3252,16
12022922    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-62,240,400,353044477,2913,16,353122480,2913,16
12022822    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,245,400,3524825984,2783,16,3524903988,2783,16
12022722    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,239,400,2401911957,2107,16,2401989960,2107,16
12022622    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-62,235,400,1278901527,784,0,1278901527,784,0
12022522    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-63,240,390,155500501,5,0,155578504,5,0
12022422    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,,246,410,1164020267,932,0,1164098270,932,0
12022322    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-69,236,400,40679820,11,0,40757823,,0
12022222    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-74,236,410,2223444155,990,30,2223444155,990,30
12022122    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,239,400,1100601616,214,0,1100679619,214,0
12022022    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-68,239,390,2047387718,8516,210,2047387718,8516,210
12021922    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-65,252,390,923908361,8141,209,923986364,8141,209
12021822    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,249,400,4095946676,3440,157,4095946676,3440,157
12021722    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-71,243,390,2972953179,2763,157,2972953179,2763,157
12021622    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,,239,390,1849873806,741,2,1849873806,741,2
12021522    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-63,236,400,726878881,677,2,726956884,677,2
12021422    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,244,390,3898600483,600,2,3898600483,600,2
12021322    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-71,241,390,2775509663,496,2,2775587667,496,2
12021222    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-71,242,390,1652694418,459,2,1652694418,459,2
12021122    ./Knock1    192.168.12.86,0:15:a3:5:f0:e8,256000000,31400000,-70,243,390,529682051,196,2,529682051,196,2
12020922    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-69,237,400,1398404488,246,0,1398482492,246,0
12020822    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-68,234,390,275157614,23,0,275235618,23,0
12020722    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-61,241,390,565317184,18025,0,565395187,18025,0
12020622    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,,31400000,,223,390,,,,3739035373,15588,
12020522    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-68,239,390,2614990117,172,0,2615068120,172,0
12020422    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-66,249,390,1492134211,96,0,1492134211,96,0
12020321    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-69,247,390,334127803,49,0,334205806,49,0
12020222    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-57,258,380,2952964014,468,322,2953042018,468,322
12020122    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-51,264,380,1829406262,438,322,1829484265,438,322
12013122    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-59,257,380,707012778,414,0,707012778,414,0
12013022    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-68,247,390,3878375400,384,0,3878375400,384,0
12012922    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-68,239,390,2755034686,357,0,2755034686,357,0
12012822    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-71,244,390,1632802728,245,0,1632802728,245,0
12012817    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,,242,390,1410649645,220,0,1410727649,220,0
12012722    ./Knock1    192.168.12.234,0:15:a3:5:f0:e8,256000000,31400000,-67,248,390,509478854,125,0,509556857,125,0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

display the file with in the date range

Hi All, I want a shell script which can display the file with in the date range. For Example I have 15 files with the following format abc_01-01-2009.txt to abc_15-01-2009.txt. Now I want to have the files between 4th of jan to 12th files. How can I acheive this. Advance... (1 Reply)
Discussion started by: fareed_do
1 Replies

2. Shell Programming and Scripting

Grepping string from out file

Guys .. Need to pull this highlighted strings irrespective of line numbers & should be echoed . But these strings are from Outfile from different dir. In which way this can be grepped ?? Need an idea http-timeout 120 seconds persistent-timeout 180 seconds host-rewriting on ... (7 Replies)
Discussion started by: raghunsi
7 Replies

3. AIX

Help with looping a file and grepping a string

I have 2 files: fileA and fileB. content of fileA --------------- admin.teacher is in new york; admin.mason is in new york; admin.driver is in new york city; user.trucker is in hartford; admin.developer is in new york state; content of fileB ---------------- admin.teacher is in... (8 Replies)
Discussion started by: lowprofile
8 Replies

4. Shell Programming and Scripting

How to search for file and display by date

I like "ls -ltr". I would like to search for a file in a large directory recursively and and display all the candidates in reverse order. /usr/bin/find . -name \*.txt This works. How do I display the date and sort the file names by the date in reverse order for the entire directory... (1 Reply)
Discussion started by: siegfried
1 Replies

5. HP-UX

find command to display size and date of a file

Hi, The blow code does not yeild any output. find . -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" -exec ls -l {} \; I wish to print the filename filesize filedate in HP-UX. Can anyone help ? (9 Replies)
Discussion started by: mohtashims
9 Replies

6. Shell Programming and Scripting

Display lines of two date range from syslog file

Hi Guys, I want to display lines from Solaris syslog file but with 2 dates range. I have some similar solution (https://www.unix.com/shell-programming-scripting/39293-grep-log-file-between-2-dates-4.html) which works fine but as you know syslog has different date format (Jan 22) so this is not... (1 Reply)
Discussion started by: prashant2507198
1 Replies

7. Shell Programming and Scripting

Extract count of string in all files and display on date wise

Hi All, hope you all are doing well! I kindly ask you for shell scripting help, here is the description: I have huge number of files shown below on date wise, which contains different strings(numbers you can say) including 505001 and 602001. ... (14 Replies)
Discussion started by: VasuKukkapalli
14 Replies

8. AIX

How do I display a file's last modified date?

I'm using a script that I need to get a file's "last modified date" in a format like 01:51:14 PM. We are running on AIX 6.1.0.0. I can't seem to find the right command parameters. Help! (4 Replies)
Discussion started by: mattadams1983
4 Replies

9. UNIX for Beginners Questions & Answers

Search a string and display its location on the entire string and make a text file

I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file. Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies

10. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy