Script that will show output starting from 24-hours earlier to present


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script that will show output starting from 24-hours earlier to present
# 8  
Old 12-22-2011
Hi balajesuri,

The code below:
Code:
for x in `ls`; do [ `stat -c%y $x | cut -c1-16 | sed 's/[- :]//g'` -ge `date -d"yesterday" +%Y%m%d%H%M` ] && echo $x; done

is used to get the FILES in the directory, what about if I want to get the logs in a file. I've tried to substitute
Code:
`cat /home/subdirectory/file`

to
Code:
`ls`

, but I think this cannot be Smilie


Please advise,
rymnd_12345
# 9  
Old 12-22-2011
Do you want to print the output (list of files satisfying the condition) in a file instead of screen?
OR
Do you want contents of each of the files listed in a separate file?

If it's the former case, just redirect the output to a filename. Try putting this at the end > list_of_files.txt

If it's the latter case, replace && echo $x; donewith && cat $x; done > temp.txt. You'll get a message on screen cat: temp.txt: input file is output file. Just ignore it. It's trying to copy contents of temp.txt into itself. If you wish, you may also write a condition to skip temp.txt.

Last edited by balajesuri; 12-22-2011 at 03:13 AM..
# 10  
Old 12-22-2011
Hi balajesuri,

Suggestion for the latter case may do.

Thanks so much!



Br,
rymnd_12345
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get output of fields starting from 2nd line

Hi All, I am using the following command in Linux: sar -r 30 3 Linux 2.6.18-194.3.1.7.3.el5xen 02/07/2013 02:55:47 PM kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad 02:56:17 PM 128646024 22348920 14.80 230232 15575860 75497464 ... (4 Replies)
Discussion started by: a1_win
4 Replies

2. UNIX for Dummies Questions & Answers

find the no of processes that ran 2 hours before or earlier

Is there a way to find out the total no of processes that were running ? - 2 or 3 hours before - list those no of processes (3 Replies)
Discussion started by: jansat
3 Replies

3. Shell Programming and Scripting

Bash script show Kill system output

Hi we are calling kill -9 $pid command from bash script it gives below output, but we need to hide the output. i tried /dev/null but ni luck. is there any alternate way to schive this. ../kill_scr.sh: line 42: 1891 Killed /tmp/anr_rest_mul_wc.sh Soalris 10. ... (2 Replies)
Discussion started by: sachinbutala
2 Replies

4. Shell Programming and Scripting

Show pages on a script's big output

Hi again: I have this code which gives an large output(several screens), and I want to display on screen at a time (like more does)....how can I do this? echo echo "Los roles en el sistema son:" echo lsrole -a dfltmsg ALL|sed 's/dfltmsg=/Descripcion=/' thanks Israel. (4 Replies)
Discussion started by: iga3725
4 Replies

5. Shell Programming and Scripting

Two files one file is dependent and it does not show an output

xxxxx (2 Replies)
Discussion started by: vinayrao
2 Replies

6. UNIX for Advanced & Expert Users

prtdiag -v show no output

Dear All....Help required prtdiag -v command shows no output on my V440 server. Following is the details: root@sdp16b>prtdiag -v root@sdp16b> root@sdp16b>uname -a SunOS sdp16b 5.9 Generic_122300-31 sun4u sparc SUNW,Sun-Fire-V440 root@sdp16b>echo $path /usr/sbin /usr/bin /usr/sbin... (6 Replies)
Discussion started by: Junaid
6 Replies

7. Shell Programming and Scripting

Help required to parse Oracle imp show=y output to DDL Commands

Hi, I generated an Oracle schema DDL script file using the show=y option of the Oracle import utility but the file that it generates needs a little more formating before we can run this as simple DDL comands to generate the schema at Target using the script file.Here is the simplified output of... (1 Reply)
Discussion started by: rajan_san
1 Replies

8. Shell Programming and Scripting

echo doesnot show output

hi every one , i m new in unix . i m trying shell scripting . set v = abc echo $v but it does not show any output . please help me (4 Replies)
Discussion started by: samy123
4 Replies

9. Shell Programming and Scripting

Scripts to output contents every 3 hours

Hi all, I would like to capture the file contents every 3 hours. I will put the schedule inside crontab, how to get only incremental contents from the last 3 hours? Thanks. (4 Replies)
Discussion started by: *Jess*
4 Replies

10. Shell Programming and Scripting

To alter perl /bin/date output by - 5 hours

Hello! I'm using a perl script which calls the time and date from a remote server using the line /bin/date - What is needed in this line to reduce the output time 5 hours? Thanks (2 Replies)
Discussion started by: Texan
2 Replies
Login or Register to Ask a Question