There is another post in the forums that is similar to what I am trying to do, however, the thread is closed. So, I am creating this new one to see if someone could help. I am trying to use the code Ahamed posted, and tweak it.
With the info from the forum, I recreated the scenario the person had, and used the last code snippet as a test to see what happened. It worked great. However, I am trying to tweak it for what I need, and was wondering if someone could help.
In my output/file I have something like this:
What I am trying to do is, pull the N00XXX row for anything over 5 weeks using the date in the last row. Not deleting any rows, need this for another function. The code looks like it converts dates to an epoch time format. Is that correct? I am able to do that using awk. EX: awk '{print "date -d\""$6FS$7FS$8"\" +%s"}' |bash
It converts the date fine, but when I try to do this in a shell script, it is a no go. In the code, it is set like this year=${val:6:4}; month=${val:3:2}; day=${val:0:2}
What are the numeric properties in this. I am guessing the second number is spacing length, like 4 is 4 spaces, and what is the first number?
Any help on this would be appreciated. Thanks!
Code from thread:
Last edited by Corona688; 09-20-2012 at 06:26 PM..
What I am trying to do is, pull the N00XXX row for anything over 5 weeks using the date in the last row. Not deleting any rows, need this for another function. The code looks like it converts dates to an epoch time format. Is that correct? I am able to do that using awk. EX: awk '{print "date -d\""$6FS$7FS$8"\" +%s"}' |bash
That's not just awk, that's awk, date, and shell.
What system do you have? In Linux, awk has the ability to do some date math natively.
Ive been a vocal of FIND command even before. Command below doesnt really give me the file that is older than two weeks.. Is there a script that will list me the log files that i want like for this date December 10, 2014, it shud list me the date between November 26, 2014 and below.
When i run... (6 Replies)
I need to grab information from the output of the ps command.
For each line of ps output that contains _progres -b I need to get the word that follows -p. The "-p" can be anywhere after "_progres -b".
Using grep to select the correct lines is no problem (e.g. ps -ef|grep "_progres \-b|grep -v... (3 Replies)
I need a command which delete files older than 10 years.
I got a command for 90 days and all commands I find are for days and nothing for years.
find file_name -mtime +90 -exec rm {} \; (5 Replies)
I have written a script which generate one logfile on every sunday and thursday
I want to move the older log files into /tmp directory befor generating new one so i used mv command like
mv usr/sbin/appl/logfile.txt usr/sbin/appl/tmp
2) But when i move this file to /tmp it will... (1 Reply)
Hi,
I'm trying to get lines from a file using identifiers in the first two columns. I have used:
cat MasterFile.txt | grep -f Pattern.txt
and the lines I want display on screen. If I try to put them in a file the file is created but stays empty:
cat MasterFile.txt | grep -f Pattern.txt... (14 Replies)
I have crontab job a tar file to a directory ( tar -cvf /tmp/backup/or.`date +%m%d%y`. /ora/db/* ) , it will do it every day . Now I don't want to keep too much files , I just want to keep the file for 90 days , can advise if I want to remove the backup file which are elder than 90 days , can... (1 Reply)
For people who want to pull a number of lines from a long file using a specific formula
n (number of iterations in a loop)
a (offset number)
b (stretch factor)
example with n {1..100}
for (( n=1; n<101; n++ )); do awk -v n=$n 'NR==a+(b*n)' a=0 b=1 inputfile >>outputfile (2 Replies)
Guys I am having a problem with being able to find missing monitors in a configuration check script I am trying to create for accountability purposes for managing a large number of systems. What I am trying to do is run a script that will look at the raw config data in a file and pull all the pool... (7 Replies)
Hi, Friends,
I am writing a script to delete all the files which are there for more than 3 weeks.
I have tried this :
find /home/appl/backup -type f -mtime +21 -exec rm -f {} \;
But i am not sure if it deletes only the files in specified directory or all the directorinies in the provieded... (3 Replies)