inspiredger.blogg.se

C shell solaris find files by date
C shell solaris find files by date




c shell solaris find files by date

The general syntax for the find command is find Įxplore more grep command examples. We will then show you how to use the -exec option to act on the files or directories based on their size, permissions, etc. This will show you how to find files and directories. In this article, we will start by explaining the basic Linux find commands with examples. Adding the -exec option enables sysadmins to run external commands and perform actions like copying, moving, deleting, or changing permissions of the files matching the specified criteria such as size, name, etc. It can find directories and files by their name, their type, or extension, size, permissions, etc.īesides locating files and directories, combining the find command with others enables you to take action on the results. You can add -mtime 42 to only match files that were modified at least 42 days ago.The Linux find command is a powerful tool that enables system administrators to locate and manage files and directories based on a wide range of search criteria.

c shell solaris find files by date

With find, you can add ! -newer somefile before -exec to only match files that are older than somefile. find /var/opt/ers/logs/rio -type f -exec sh -c ' If you need to look for files in subdirectories recursively, call find to iterate over all the files and, again, execute the shell snippet for each file. If you really need to have abbreviated month names and the DMY order, use ls -e instead of ls -E and change the awk call accordingly: mdy=$(ls -eog "$f" | awk '') I recommend the Y-M-D format because it sorts in chronological order. Note that the archive directories will have names like RIO_ rather than RIO_3. Target=/ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/RIO_$ymd For each file, obtain the date, create the target directory if needed, and move the file. Iterate over all the files in the log directory.

c shell solaris find files by date

Under Solaris, you can get a file's date in a usable format with ls -E.






C shell solaris find files by date