Sponsored Content
Top Forums Shell Programming and Scripting Delete all instances of a particular file in that month Post 302961003 by lohith.dutta on Monday 23rd of November 2015 04:14:47 AM
Old 11-23-2015
hi Hypesslearner,
Can you please share some input and desire outputs also please refer some example naming convention you are using ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete files one day old in current month only

i want to delete files that are one day old condition is files should be of current month only ie if iam running script on 1 march it should not delete files of 28 feb(29 if leap year :-)} any modifications to find $DIR -type f -atime +1 -exec rm -f{}\; (4 Replies)
Discussion started by: maverick
4 Replies

2. UNIX for Dummies Questions & Answers

Multiple file instances

I am capturing text based reports with a specific program, which works no problem. However, since I send report warehouse output as they are migrated from the database software, on occasion when two capture process' initiate simultaneously, the capture file locks up. Is there a way to setup (in... (1 Reply)
Discussion started by: gozer13
1 Replies

3. UNIX for Dummies Questions & Answers

Delete filename with month -2

KSH - I've got a script that is generating a number of log files like this: y=`date +"%y"` m=`date +"%m"` $LOG_DIR/tuscprof_tbl_$y$m.log I only want to keep the current 2 months' worth of files (current month and prior month). So I'm trying to come up with a way to delete any that... (1 Reply)
Discussion started by: dstinsman
1 Replies

4. Shell Programming and Scripting

Replacing all instances of an IP address in a log file.

I know this should be simple but the periods in the string replacement are throwing me off. What I want to do is replace 1.1.1.1 in my access.log file with 2.2.2.2 I have tried using 'tr' but its being thrown off by the periods and replacing all sorts of stuff in the file. What do I need... (2 Replies)
Discussion started by: LordJezo
2 Replies

5. Shell Programming and Scripting

Remove all instances of duplicate records from the file

Hi experts, I am new to scripting. I have a requirement as below. File1: A|123|NAME1 A|123|NAME2 B|123|NAME3 File2: C|123|NAME4 C|123|NAME5 D|123|NAME6 1) I have 2 merge both the files. 2) need to do a sort ( key fields are first and second field) 3) remove all the instances... (3 Replies)
Discussion started by: vukkusila
3 Replies

6. Shell Programming and Scripting

How to select only the most frequent instances of a variable string in a file?

I've got a web access file that I want to grep (or awk or perl or whatever will work!) out the most frequent instances of unique IP entries. Meaning the file looks something like this: I'd like to run a sort or grep (or whatever) that will only select out the lines from IP's that had the... (7 Replies)
Discussion started by: kevinmccallum
7 Replies

7. UNIX for Dummies Questions & Answers

Deleting all instances of a certain character from a text file

In my command prompt I did: sed 's/\://' mytextfile > newtextfile But it only deleted the first instance of : in each line when some lines have multiple : appearing in each one. How can I delete all the : from the entire file? (1 Reply)
Discussion started by: guitarscn
1 Replies

8. Shell Programming and Scripting

Delete duplicate data and pertain the latest month data.

Hi I have a file with following records It contains three months of data, some data is duplicated,i need to access the latest data from the duplicate ones. for e.g; i have foll data "200","0","","11722","-63","","","","11722","JUL","09" "200","0","","11722","-63","","","","11722","JUL","09"... (10 Replies)
Discussion started by: vee_789
10 Replies

9. Shell Programming and Scripting

replacing all instances in a file

Hi I have some script like this: perl -i -p0e 's/"keyword1-.*?"/"keyword2"/s' file to replace some keyword, but it replaces only the first instance of the keyword how can i get it to replace all instances? thanks! (2 Replies)
Discussion started by: vanessafan99
2 Replies

10. UNIX for Beginners Questions & Answers

Hadoop directories delete older than a month

-bash-4.1$ hdfs dfs -ls -R /data/backup/prd/xyz/ | grep '^d' drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180301 drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180302 drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03... (2 Replies)
Discussion started by: himanshupant
2 Replies
rename(2)							System Calls Manual							 rename(2)

NAME
rename - change the name of a file SYNOPSIS
DESCRIPTION
The system call causes the source file to be renamed to target. If target exists, it is first removed. Both source and target must be of the same type (that is, either directories or nondirectories), and must reside on the same file system. If target can be created or if it existed before the call, guarantees that an instance of target will exist, even if the system crashes in the midst of the operation. If the final component of source is a symbolic link, the symbolic link is renamed, not the file or directory to which the symbolic link points. RETURN VALUE
returns the following values: Successful completion. Failure. Neither file is affected. is set to indicate the error. ERRORS
If fails, is set to one of the following values. [EACCES] A component of either path prefix denies search permission. [EACCES] The requested link requires writing to a directory without write permission. [EBUSY] target or source is an existing directory that is the mount point for a mounted file system. [EDQUOT] User's disk quota block or inode limit has been reached for this file system. [EEXIST] target is a directory and is not empty. [EFAULT] source or target points outside the allocated address space of the process. Reliable detection of this error is implementation dependent. [EINVAL] source is a parent directory of target, or an attempt is made to rename the or directory. [EISDIR] target is a directory, but source is not. [ELOOP] Too many symbolic links were encountered in translating either path name. [ENAMETOOLONG] A component of either path name exceeds bytes while is in effect, or the entire length of either path name exceeds bytes. [ENOENT] A component of the source path does not exist, or a path prefix of target does not exist. [ENOSPC] The destination directory cannot be extended because of a lack of space on the file system containing the directory. [ENOTDIR] A component of either path prefix is not a directory. [ENOTDIR] source is a directory, but target is not. [EPERM] The directory containing source has the sticky bit set, and neither the containing directory nor the source are owned by the effective user ID. [EPERM] The target file exists, the directory containing target has the sticky bit set, and neither the containing directory nor the target are owned by the effective user ID. [EROFS] The requested link requires writing in a directory on a read-only file system. [EXDEV] The paths named by source and target are on different logical devices (file systems). AUTHOR
was developed by the University of California, Berkeley. SEE ALSO
open(2). STANDARDS CONFORMANCE
rename(2)
All times are GMT -4. The time now is 11:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy