Need to check a file from a certain position onwards


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to check a file from a certain position onwards
# 8  
Old 01-23-2012
Did you check my second point?

Quote:
And your file seems to have date with dotted notation and the date you are passing to awk is without dots.
--ahamed

---------- Post updated at 06:31 AM ---------- Previous update was at 06:29 AM ----------

Shouldn't date be passed like this? date +%d.%m.%Y

--ahamed
# 9  
Old 01-23-2012
Code:
+ awk $' BEGIN {ok=0}\n   $(NF-1)==YESTERDAY &&  substr($(NF),1,2) >= 15 {ok=1}\n            ok==0 {next}\n        {print} ' DATE11=20120123 YESTERDAY1=20120122 /usr/openv/netbackup/bin/MEDIA_DEASSIGN_CALLED.20120122

# 10  
Old 01-23-2012
Check my previous post (#8) for the date format!

--ahamed
# 11  
Old 01-23-2012
Yes it is being passed like that my friend

Code:
SCRIPT
 awk ' BEGIN {ok=0}
   $(NF-1)==YESTERDAY1 &&  substr($(NF),1,2) >= 15 {ok=1}
        ok==0 {next}
        {print} ' DATE11=`date +%d.%m.%Y` YESTERDAY1=`date -d "$DATE11 last day " "+%d.%m.%Y"`  /usr/openv/netbackup/bin/MEDIA_DEASSIGN_CALLED.$YESTERDAY | grep label | egrep -v "MEDIA_DEASSIGN_CALLED|NEEDS LABELLING|LABELED "

Code:
OUTPUT
+ awk $' BEGIN {ok=0}\n   $(NF-1)==YESTERDAY &&  substr($(NF),1,2) >= 15 {ok=1}\n         {print} ' DATE11=23.01.2012 YESTERDAY1=22.01.2012 /usr/openv/netbackup/bin/MEDIA_DEASSIGN_CALLED.20120122

---------- Post updated at 02:37 PM ---------- Previous update was at 02:35 PM ----------

Working now... me being silly, with the string name... Many thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk - $9 and onwards

How can I get awk to print all fields from $9 and onwards? (2 Replies)
Discussion started by: locoroco
2 Replies

2. Shell Programming and Scripting

Script to count matched string then check again from last read position

Hi all, I am currently trying to figure out how can i capture a particular string from a log file, then search again but from the last line it read before onward. Basically let's say that the check runs every 5 mins via cron, counting the number of matched strings "Cannot assign requested... (5 Replies)
Discussion started by: nms
5 Replies

3. Shell Programming and Scripting

How to check charactor in certain position?

Hi Gurus, I need to check the charactor in certain position. in my file abcdef1234gh ac1234eeeegt acdead1235gh I want to check what is check from position 7 to 10's charactor, if it is 1234, then output the whole line. for above file, I want to get below output abcdef1234gh... (2 Replies)
Discussion started by: ken6503
2 Replies

4. Shell Programming and Scripting

Need to check a file from a certain position and date onwards

Hi Guys, I need some advice please. My script is not grabbing information from a text file from a certain date correctly. It seems to be grabbing everying in the file, i know it is something simple but i have looked to hard and to long, to know what the issue is. Script awk '... (9 Replies)
Discussion started by: Junes
9 Replies

5. Shell Programming and Scripting

Sort a file from specific row onwards

Hello All: I've file in below format. File name is "FIRSTN.TBL": AAAAAA N BBBBBBBBBBBBBBBBBBBBBBB N . . . . ZZZZZZZZZZZZZZZZZZZZZZZZZZ N My file row length is 40 characters and my second column will start from 25th column and it is only... (3 Replies)
Discussion started by: nvkuriseti
3 Replies

6. UNIX for Dummies Questions & Answers

Using grep to check for character at fixed position

i have a file (test.txt) that contains: 20799510617900000928000000005403020110315V 20799510617900000928000000005403020110316 20799510617900000928000000005403020110317 20799510617900000928000000005403020110318V grep V test.txt > /tmp/void.log if then mail -s "void" < test.txt fi... (2 Replies)
Discussion started by: tjmannonline
2 Replies

7. Shell Programming and Scripting

Moving first position in a file to the last position

hi, I have a file which consists of some records: 2010_06_4010093_001_001|10|ABCDEFGH|9|4010093||0040400||31.12.2009|S|O|X||||20100602093851-31.12.2009|XXBBFC|EFG||||00001| 2010_06_4010162_001_001|11|ABCDEFGH|9|4010162||0040400||31.12.2009|S|O|X||||20100602093851-31.12.2009|XXBBFC|EFG||||00002|... (11 Replies)
Discussion started by: pparthiv
11 Replies

8. Shell Programming and Scripting

How to check a word position in a file ?

Hello everybody, I have a file like this : "window 1 truck 3 duck 2... fire 1... etc..." and I would like to print the following number of a word I am searching for. (For example here, if I search for the word "fire", I will print "1") Thank you for your help ! (7 Replies)
Discussion started by: tibo
7 Replies

9. Shell Programming and Scripting

check position of end of line(URGENT PLS)

I Have to check in a file that all the lines are ending at same posiotin. Ex : line 1 is ending at position 88 line 2 should at same position i.e 88 Thanks in advance (6 Replies)
Discussion started by: evvander
6 Replies

10. Shell Programming and Scripting

check position of end of line for some specific lines

-------------------------------------------------------------------------------- Have to check in a file that the lines starting with 620 and 705 are ending at same posiotin. 82012345 62023232323 70523949558 62023255454 9999 In the above lines, i have to check the lines starting... (1 Reply)
Discussion started by: senthil_is
1 Replies
Login or Register to Ask a Question