Remove data from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove data from file
# 1  
Old 09-30-2013
Remove data from file

Hi

I have file with filename as below and need to remove based on date in it.

Data in file:
Code:
filename_092013.csv
filename_082013.csv
filename_072013.csv

I want to remove filenames which are generated 15 days back. where date is generated in file. I need to create another file with filename which are created in last 15 days.
# 2  
Old 10-01-2013
Hi,

Could you please provide more information on your date formate
(like . DDMMYYY or something else ) ?
Please check filename, provided in your first post and let us know.

Thanks
Pravin
# 3  
Old 10-01-2013
Hi Pravin,

Date format is MMDDYY.
filename_<MMDDYY>.csv

What i want to do is I just want a file with last 15 days of files. rest should be removed from file.

Please let me know if you need any more information.

Thanks
# 4  
Old 10-01-2013
Remove files older than 15 days from the current directory
Code:
find . -type f -name '*.csv' -mtime +15 -exec echo rm -f {} \;

It uses the file modification time as shown by ls -t - not the date in the filename.
If you think it lists the correct rm commands, remove the echo to really run it.
# 5  
Old 10-01-2013
Thanks

But I dont want to remove files in the directory. I have list of filenames in one file. all file names should be removed based on date in filename.
# 6  
Old 10-01-2013
Please explain in more detail.

I think MadeInGermany has answered your question.

What are you trying to do?
# 7  
Old 10-02-2013
Hi hicksd8

What i am trying to do is I have one text file(Eg:Filelist.txt) It has list of filenames(Filenames are contained with date as mentioned in the initial post)

I want remove the filenames from the Filelist.txt file and create new file with valid filenames

Validation Process: all filenames should not be belongs to not more than 15 days.

Note: Not from the filesystem files we are deleting filenames from one text file and creating new file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove new line characters from data rows in a Pipe delimited file?

I have a file as below Emp1|FirstName|MiddleName|LastName|Address|Pincode|PhoneNumber 1234|FirstName1|MiddleName2|LastName3| Add1 || ADD2|123|000000000 2345|FirstName2|MiddleName3|LastName4| Add1 || ADD2| 234|000000000 OUTPUT : ... (1 Reply)
Discussion started by: styris
1 Replies

2. Post Here to Contact Site Administrators and Moderators

Please remove sensitive data

Hi Kindly remove the following from the post . These are confidential info posted by mistake https://www.unix.com/shell-programming-and-scripting/201037-perl-while-loop-each.html please remove the comments section which is first 16 lines in the perl script . Also please remove the ... (1 Reply)
Discussion started by: ptappeta
1 Replies

3. Post Here to Contact Site Administrators and Moderators

Remove sensitive data

Hi Sir, please remove following terms from post as it is sensitive data https://www.unix.com/shell-programming-and-scripting/235655-print-single-line.html ifeeds fidedev ironsides feedmgr thanks a lot prabhu (1 Reply)
Discussion started by: ptappeta
1 Replies

4. Shell Programming and Scripting

Remove data from grep command using the pattern in the file

Hi, I writing a shell program to remove the data from output of the find which matches a list in a file I am using the below find command to get the list of files x=`find . -name test*.dat` the output of the find command is as follows test1.dat test2.dat test3.dat test4.dat... (4 Replies)
Discussion started by: pals70423
4 Replies

5. Shell Programming and Scripting

Remove brackets { } in the data

Hello folks, I have a data file in which each line has 54 numbers, and every 3 numbers are bracketed. So totally 18 pairs of brackets in each line. A typical line is like: {29.187000274658203 -16.148000717163086 -0.9380000233650208} {30.63800048828125 -15.977999687194824... (5 Replies)
Discussion started by: rockytodd
5 Replies

6. Shell Programming and Scripting

remove a column of data

Hi my file has two columns: GAII_4:6:100:548:645/1 GTACACAACCCCCCCCCCCCACCCCACCCCCCCCCCCCCC GAII_4:6:100:1:1242/1 AGTCTGCCCCTCCCCCTNNNNNNNTCTTTTNCCTCCTCCT GAII_4:6:100:444:504/1 GTAACACACACCCTGATACTCCCCCCTCCACAACCGCTCT I want to remove the first column and keep only the scond column so it... (1 Reply)
Discussion started by: jdhahbi
1 Replies

7. Shell Programming and Scripting

Remove Headers throughout a data file

I have a data file with over 500,000 records/lines that has the header throughout the file. SEQ_ID Name Start_Date Ins_date Add1 Add2 1 Harris 04/02/08 03/02/08 333 Main Suite 101 2 Smith 02/03/08 01/23/08 287 Jenkins SEQ_ID Name ... (3 Replies)
Discussion started by: psmall
3 Replies

8. Shell Programming and Scripting

Remove unwanted data?

Hi Can any one help me remove the unwanted data? I would want to remove the complete event id 4910 ( the type there is INFO), that means, I have to remove starting from 7th - 19th lines. can any one of you please help? Thanks, (24 Replies)
Discussion started by: hitmansilentass
24 Replies

9. Shell Programming and Scripting

Remove & insertion of data in a same file

I am iterating record by record through a file as below, A,B A,C A,D B,E B,F E,G E,H The same file should look like in the final output as below, A,B B,E E,G E,H B,F A,C A,D (10 Replies)
Discussion started by: videsh77
10 Replies

10. UNIX for Dummies Questions & Answers

Remove Data from Fields

I would like some sugestions on how to solve the following problem with removing selected data from fields. Each day I receive a file containing 22,000 records that I use a combination of awk and the cut command to remove unwanted fields. This is a work in process as I learn more about awk, sed... (4 Replies)
Discussion started by: greengrass
4 Replies
Login or Register to Ask a Question