Sponsored Content
Top Forums Shell Programming and Scripting Shell script to check current date file is created and with >0 kb or not for multiple directories Post 303019692 by Pinaki on Wednesday 4th of July 2018 09:18:35 AM
Old 07-04-2018
Code:
#!/bin/bash
_file="$1"
[ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 1; }
[ ! -f "$_file" ] && { echo "Error: $0 file not found."; exit 2; }

if [ -s "$_file" ]
then
        echo "$_file has some data."
else
        echo "$_file is empty."
fi

Hi Ravi,

I have found this one but from this script while running I have to mention the file name. But what I actually require is to check the current date files size from multiple folders.

Regards,
Pinaki

---------- Post updated at 06:48 PM ---------- Previous update was at 01:41 PM ----------

Hi Rovf,

Yes I got some hints. It can be done through the for loop to check the files for multiple directories. Though I am new but yet I am just trying to create that. Thank you for your suggestion.

Regards,
Pinaki
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to check whether the given file is 5 weeks older than current date

HI, I need to check whether the given file is 5 weeks older than current date ?? Can anyone give me the script for this ?? (1 Reply)
Discussion started by: risshanth
1 Replies

2. Solaris

check the current date file in directory

Hi, I am making a script which check the directory and if there is today date file, it is showing message file is there for today date . 1) filename is accessline.win.$timestamp example ;-accessline.win.200712211004 2) On monday i have recieved two file in this directory with current... (2 Replies)
Discussion started by: pallvi
2 Replies

3. Shell Programming and Scripting

Recursive call to find files and directories in Shell script from current path.

################################################################ Copy this script to your path from where you want to search for all the files and directories in subdirectories recursively. ################################################################# code starts here... (2 Replies)
Discussion started by: Ramit_Gupta
2 Replies

4. Shell Programming and Scripting

Shell Script to compare files, check current date and count

Hello - I have written the following basic shell script to count files, compare files and look for a particular strings in a file. Problem 1: How do I define more than 1 file location? #!/bin/bash #this is a test script FILES=$(ls /home/student/bin/dir1, home/student/bin/dir2)... (0 Replies)
Discussion started by: DallasT
0 Replies

5. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

6. Shell Programming and Scripting

Script to Search Logs Several Directories Pulling out Only Current Date

Hi All.. I'm seeking assistance with editing a script to search log files in several directories. I'm close to what I'm seeking, but need additional guidance. The log files are always listed by current date; however, inside the log file includes dates that go back to 2011. What I'm... (6 Replies)
Discussion started by: lenaf7
6 Replies

7. Shell Programming and Scripting

Find the file created on current date

Hi All, I'm trying to find a file which is created on current day.... I searched in unix.com and i found, below command. find /land/ -mtime -1 -type f -print | grep "FF_Member_STG.dat" The command checks if the file with name "FF_Member_STG.dat" is created today then exit else proceed. ... (3 Replies)
Discussion started by: ace_friends22
3 Replies

8. Shell Programming and Scripting

Shell script replied multiple process for file has successfully created

Hi All, I have written the following code do FILE_NO=$(echo $LINE|awk -F"|" '{print $1}'|tr "'" '+'|sed 's/\(.*\)\(++\)\(.*\)\(++\)/\3/') INST_NO=$(echo $LINE|awk -F"|" '{print $2}'|tr "'" '+'|sed 's/\(.*\)\(++\)\(.*\)\(++\)/\3/') if ] then ... (3 Replies)
Discussion started by: yogendra.barode
3 Replies

9. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

10. Linux

How to calculate the quarter end date according to the current date in shell script?

Hi, My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies
enable_extended_FILE_stdio(3C)				   Standard C Library Functions 			    enable_extended_FILE_stdio(3C)

NAME
enable_extended_FILE_stdio - enable extended FILE facility within standard I/O SYNOPSIS
#include <stdio.h> #include <stdio_ext.h> #include <signal.h> int enable_extended_FILE_stdio(int low_fd, int signal_action); DESCRIPTION
The enable_extended_FILE_stdio() function enables the use of the extended FILE facility (see NOTES) and determines which, if any, signal will be sent when an application uses FILE->_file inappropriately. The low_fd argument specifies the lowest file descriptor in the range 3 through 255 that the application wants to be selected as the unal- locatable file descriptor. File descriptors 0, 1, and 2 cannot be used because they are reserved for use as the default file descriptors underlying the stdin, stdout, and stderr standard I/O streams. The low_fd argument can also be set to -1 to request that enable_extended_FILE_stdio() select a "reasonable" unallocatable file descriptor. In this case, enable_extended_FILE_stdio() will first attempt to reserve a relatively large file descriptor, but will keep trying to find an unallocatable file descriptor until it is known that no file descriptor can be reserved. The signal_action argument specifies the signal that will be sent to the process when the unallocatable file descriptor is used as a file descriptor argument to any system call except close(2). If signal_action is -1, the default signal (SIGABRT) will be sent. If signal_action is 0, no signal will be sent. Otherwise, the signal specified by signal_action will be sent. The enable_extended_FILE_stdio() function calls unallocatablefd = fcntl(low_fd, F_BADFD, action); to reserve the unallocatable file descriptor and set the signal to be sent if the unallocatable file descriptor is used in a system call. If the fcntl(2) call succeeds, the extended FILE facility is enabled and the unallocatable file descriptor is saved for later use by the standard I/O functions. When an attempt is made to open a standard I/O stream (see fdopen(3C), fopen(3C), and popen(3C)) with an underly- ing file descriptor greater than 255, the file descriptor is stored in an auxiliary location and the field formerly known as FILE->_file is set to the unallocatable file descriptor. If the file descriptor limit for the process is less than or equal to 256 (the system default), the application needs to raise the limit (see getrlimit(2)) for the extended FILE facility to be useful. The enable_extended_FILE_stdio() function does not attempt to change the file descriptor limit. This function is used by the extendedFILE(5) preloadable library to enable the extended FILE facility. RETURN VALUES
Upon successful completion, enable_extended_FILE_stdio() returns 0. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The enable_extended_FILE_stdio() function will fail if: EAGAIN All file descriptors in the inclusive range 3 through 255 refer to files that are currently open in the process. EBADF The low_fd argument is greater than 255, or is less than 3 and not equal to -1. EEXIST A file descriptor has already been marked by an earlier call to fcntl(). EINVAL The signal_action argument is not -1, is not 0, and is not a valid signal number. USAGE
The enable_extended_FILE_stdio() function is available only in the 32-bit compilation environment. The fdopen(3C), fopen(3C), and popen(3C) functions all enable the use of the extended FILE facility. For source changes, a trailing F char- acter in the mode argument can be used with any of these functions if the FILE *fptr is used only within the context of a single function or group of functions and not meant to be returned to a caller. All of the source code to the application must then be recompiled, thereby exposing any improper usage of the FILE structure fields. The F character must not be used if the FILE *fptr is to be returned to a caller. The calling application might not understand how to process it. Alternatively, the enable_extended_FILE_stdio() function can be used at a higher level in the code. Use extendedFILE(5) for binary relief. EXAMPLES
Example 1 Increase the file limit and enable the extended FILE facility. The following example demonstrates how to programmatically increase the file limit and enable extended FILE facility. (void) getrlimit(RLIMIT_NOFILE, &rlp); rlp.rlim_cur = 1000; /* set the desired number of file descriptors */ retval = setrlimit(RLIMIT_NOFILE, &lrp); if (retval == -1) { /* error */ } /* enable extended FILE facility */ retval = enable_extended_FILE_stdio(-1, SIGABRT); if (retval == -1) { /* error */ } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsl (32-bit) | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
close(2), fcntl(2), getrlimit(2), fdopen(3C), fopen(3C), popen(3C), signal.h(3HEAD), stdio(3C), attributes(5), extendedFILE(5) NOTES
Historically, 32-bit Solaris applications have been limited to using only the file descriptors 0 through 255 with the standard I/O func- tions (see stdio(3C)) in the C library. The extended FILE facility allows well-behaved 32-bit applications to use any valid file descriptor with the standard I/O functions. For the purposes of the extended FILE facility, a well-behaved application is one that: o does not directly access any fields in the FILE structure pointed to by the FILE pointer associated with any standard I/O stream, o checks all return values from standard I/O functions for error conditions, and o behaves appropriately when an error condition is reported. The extended FILE facility generates EBADF error returns and optionally delivers a signal to the calling process on most attempts to use the file descriptor formerly stored in FILE->_file as an argument to a system call when a file descriptor value greater than 255 is being used to access the file underlying the corresponding FILE pointer. The only exception is that calls to the close() system call will return an EBADF error in this case, but will not deliver the signal. The FILE->_file has been renamed to help applications quickly detect code that needs to be updated. The extended FILE facility should only be used by well-behaved applications. Although the extended FILE facility reports errors, applica- tions that directly reference FILE->_file should be updated to use public interfaces rather than rely on implementation details that no longer work as the application expects (see __fbufsize(3C) and fileno(3C). This facility takes great care to avoid problems in well-behaved applications while maintaining maximum compatibility. It also attempts to catch dangerous behavior in applications that are not well-behaved as soon as possible and to notify those applications as soon as bad behavior is detected. There are, however, limitations. For example, if an application enables this facility and is linked with an object file that had a stan- dard I/O stream using an extended FILE pointer, and then used the sequence (void) close(FILE->_file); FILE->_file = myfd; to attempt to change the file descriptor associated with the stream, undesired results can occur. The close() function will fail, but since this usage ignores the return status, the application proceeds to perform low level I/O on FILE->_file while calls to standard I/O func- tions would continue to use the original, extended FILE pointer. If the application continues using standard I/O functions after changing FILE->_file, silent data corruption could occur because the application thinks it has changed file descriptors with the above assignment but the actual standard I/O file descriptor is stored in the auxiliary location. The chances for corruption are even higher if myfd has a value greater than 255 and is truncated by the assignment to the 8-bit _file field. Since the_file field has been renamed, attempts to recompile this code will fail. The application should be changed not to use this field in the FILE structure. The application should not use this facility if it uses _file directly, including using the fileno() macro that was provided in stdio.h(3HEAD) in Solaris 2.0 through 2.7. SunOS 5.11 18 Apr 2006 enable_extended_FILE_stdio(3C)
All times are GMT -4. The time now is 06:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy