![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I find files by date or size from stout? | umen | UNIX for Dummies Questions & Answers | 2 | 01-13-2008 06:04 AM |
| shell script to find files by date and size | dadadc | UNIX for Dummies Questions & Answers | 1 | 10-20-2007 02:18 AM |
| command to find out total size of a specific file size (spread over the server) | abhinov | SUN Solaris | 3 | 08-08-2007 03:48 AM |
| Delete file by date or by size | odogbolu98 | Filesystems, Disks and Memory | 1 | 03-14-2002 04:00 PM |
| find the file by size | rooh | UNIX for Dummies Questions & Answers | 1 | 08-16-2001 04:21 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Find file size and date
Hi in my shell script I have to do this
1. there is a file called testing.txt in /home/report directory If the file size is 0(zero) and date is today's date, then I have to print "Successful" else "Failed". 2. There is a file called number.txt which will have text only one line like this 20080324|0000040768 the first 8 digits is date. I have to check if that date is today's date, if so print 40768. I mean I have to trim 0000040768 to 40768. Any help is appreciated. Regards, G. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Why is this in the "Advanced" forum? Looks like homework anyway.
|
|
#3
|
|||
|
|||
|
What?
your perception is wrong
Any body who is expert in a different field and had to get some work done in unix can post such questions. Could help you if you have any doubts in ORACLE. Regards, G. |
|
#4
|
|||
|
|||
|
1.
Code:
#!/bin/ksh
touch -t `+%Y%m%d0000` ./dummy
count=0
find /home/report -name testing.txt -newer ./dummy | \
while read file
do
let count=$count+1
done
if [[ $count -eq 1 ]] ; then
echo "Success"
else
echo "Failure"
fi
Code:
awk -F'|' '{print $1}' number.txt | read today number
if [[ $today = "`date +%Y%m%d`" ]] ; then
printf "%d\n" $number
fi
|
|
#5
|
|||
|
|||
|
I couldn't get the second script to work. (Didn't try the first.) How about this instead:
Code:
IFS='|' read date number <number.txt case $date in `date +%Y%m%d`) printf "%d\n" "$number";; esac |
|
#6
|
|||
|
|||
|
How's this for the first.
Code:
if find /home/report -maxdepth 1 -mtime -1 -name testing.txt -size 0 | grep . >/dev/null then echo Success else echo Failure fi |
|
#7
|
|||
|
|||
|
Input
Hi,
really appreciate the input but still throwing errors first one error find: 0652-017 -maxdepth is not a valid option. secon one error printf: 3016-002 00004268 is not completely converted. Any Ideas plz. Regards, G. |
|||
| Google The UNIX and Linux Forums |