Remove files older than 18 months in UNIX (date in file name, not timestamp) - unix

I want to delete log files which are older than 18 months from a directory. But deletion should not be based on the timestamp of file.
It should be based on the name of file.
Kindly help us to remove these files?
S14444225.SLS.20150131073838 (No need to Delete),
C14444210.ITM.20150131073838 (No need to Delete),
O14444216.OUT.20150131073838(No need to Delete),
S14444225.SLS.20130131073838(need to be Deleted),
C14444210.ITM.20130131073838(need to be Deleted),
O14444216.OUT.20130131073838(need to be Deleted)

Related

I'm looking for a way to search for and delete files which end in a specific character

I have a large ebook library which I have somehow managed to duplicate. Each .pdf is stored within its own individual folder inside a directory.
The pdf's have been duplicated in their original location, and have an identical file name except with a "2" at the end of each file name.
Is there a way to automatically delete all files within a directory, and all subdirectories, whose file name ends with a "2"?
For example, in one directory there are two files:
"Tolle_2001_thepowerofnow.pdf"
"Tolle_2001_thepowerofnow2.pdf"
I would like to delete the second file, but there are thousands of these folders in my ebook directory.
Thanks for your help!

Why does the group of some file show number (looks like ID), not an alphabet string?

Normally as 'ls -al', the files always show like:
-rw-r--r-- 1 owner_name group_name size time file_name
But some of my files show:
-rw-r--r-- 1 owner_name 'number' size time file_name
And the 'number' does not exist in /etc/group
What does the 'number' mean? and how to fix it?
Many thanks!
The number is the group ID (gid). Groups and Users in a *nix system are numerical IDs (uid and gid). In a file system, the owning user and group will only ever be stored by its ID.
To display this, the user database is queried. With a modern *nix system, this could be anything, e.g. an LDAP directory, but the classic format is using the files /etc/passwd and /etc/group. If you see an ID instead of a name, it means your system couldn't find the entry in the user/group database. With a remote LDAP directory, this happens e.g. when the network is down. If you just use a traditional /etc/group file, this only happens when there is no entry.
Either the group was deleted or somebody changed the group of the file using a (non-existing) ID instead of a name or the file was copied from another system having this group and preserving the IDs while copying.
How to fix it depends on what you want. You can just chgrp the file to an existing group. Or you can create a group with this ID.
The numbers will be the group id's as opposed to the group name. To display group id's without group names, you can use ls -aln.
If a number shows amongst the names this is normally an issue with group name resolution i.e. if a group of files have been downloaded from an outside source and the group id's/names are "foreign" and therefore not understood by the local system.

Download files without knowing the extensions

I had an excel file which had for each row a column named id with a link value that open up other files the id doesn't have .(extension) on it.
The problem is that I imported the excel file on SQL Server Management, and the links is now strings without extension i want it to be displayed as a link in my grid view on asp.net page to open up the named file...
To mention there is at least 700 rows on the database.
Thanks in advance!

Read a CSV file that have indefinite number of columns every time and create a table based on column names in csv file

I have a requirement to load the csv into DB using oracle apex or pl/sql code, but the problem is they are asking to load the csv file which will not come with same number of columns and column names .
I should create table & upload data dynamically based on the file name and data that i'm uploading.
For every file i need to create a new table dynamically and insert data that are present in csv file.
For Example:
File1:
col1 col2 col3 col4 (NOTE: If i upload File 1, Table should be created dynamically based on the file name and table should contain same column name and data same as column headers of csv file . )
file 2:
col1 col2 col3 col4 col 5
file 3:
col4 col2 col1 col3
Depending on the columns and file name i need to create table for every file upload.
Can we load like this or not?
If yes, Please help me on this.
Regards,
Sachin.
((Where's the PL/SQL code in this solution!!??! Bear with me... the
answer is buried in here somewhere... I introduced some considerations
and assumptions you will need to think about before going into the
task. In the end, you'll find that Oracle APEX actually has a
built-in solution that satisfies exactly what you've specified... with
some caveats.))
If you are working within the Oracle APEX platform, you will have some advantages. APEX Version 4.2 and higher has a new page element called "Data Loading". The disadvantage however is that the definition of the upload target is fixed and not dynamic. You will need to know how your table is structured prior to loading the data.
One approach to overcome this is to build a generic, two-column table as your target, which will serve for all uploads. Column 1 will be your file-name and column two will be a single clob data type, which will contain the entire data file's contents including the header row. The "Data Loading" element will give the user the opportunity to verify and select this mapping convention in a couple of clicks.
At this point, it's mostly PL/SQL backend work doing the heavy lifting to parse and transform the data uploaded. As far as the dynamic table creation, I have noticed that the Oracle package, DBMS_SQL allows the execution of DDL SQL commands, which could be the route to making custom tables.
Alex Poole's comment is important as well, you will need to make some blanket assumption about the data type or have a provision to give more clues about what kind of data is contained. Assuming you can rely on a sample of existing data values is not good... what if all the values in your upload are null? I recommend perhaps a second column in the data input with a clue about the type of data for each column... just like the intended header names, maybe: AAAAA = for a five character column, # = for a numeric, MM/DD/YYYY = for a date with a specific masking.
The easier route:
You will need to allow your end-user access to a developer-role account on a workspace of your APEX server. It is not as scary as you think. With careful instruction and some simple precautions, I have been able to make this work with even the most non-technical of users. The reason for this is that there is a more powerful upload tool found under the following menu item:
SQL Workshop --> Utilities --> Data Workshop
There is a choice under "Data Load" --> "Spreadsheet Data"
The data load tool will automatically do the following:
Accept a CSV formatted file through a browse function on your client machine
Upload the file and parse the first record for the column layout (names)
Allow the user to create a new table from the uploaded file, or to map to an existing one.
For new tables, each column data type can be declared and also a specific numeric/date mask if additional conversion from the uploaded data is necessary.
Delimiter type, optional enclosures (like double quotes), decimal conventions and currency types can also be declared prior to parsing the uploaded file.
Once the user has identified all these mappings and settings, the table is created with the uploaded data. Any errors in record upload are reported immediately afterwards with detailed feedback on the failed records.
A security consideration to note:
You probably do not want to give end users access to your APEX server's backend... but you CAN create a new workspace... just for your end users... create a new database schema for receiving their uploads, maybe with some careful resource controls. Developer is the minimum role needed... but even if the end users see the other stuff there won't be access to anything important from an isolated workspace.
I have implemented the isolated workspace approach on a 4.0/4.1 release APEX platform a few years back, and it worked nicely. Our end user had control over the staging and quality checking of her data inputs (from excel spreadsheet/csv exports collected from a combination of sources). I suppose it may have been even better to cut her out of the picture entirely and focused on automating the export-review-upload process between our database and her other sources. In this case, the volume of data involved was not great enough (100's to 1000's of records) and the need for manual review and edit of the exported data was very important prior to pushing it into the database... so the human element was still important in this case - it is something you'll want to think about now.

Filter on directory and all subdirectories in Google Analytics

I am trying to set up a filter to include only data for a particular directory and all its sub directories.
For example, I would like to include data from dogs directory and subdirectories
http://www.mysite.com/dogs/
http://www.mysite.com/dogs/index.htm
http://www.mysite.com/dogs/breeds.htm
http://www.mysite.com/dogs/puppies/
http://www.mysite.com/dogs/puppies/index.htm
http://www.mysite.com/dogs/puppies/care/
http://www.mysite.com/dogs/puppies/care/feeding.htm
When creating a new filter I think I should select a Pre-defined filter to Include only traffic to the subdirectories that begin with the subdirectory /dogs/ and not case sensitive.
I am just a bit confused about whether it should be that begin with or that are equal to. Am I right to use that begin with in my situation and is my subdirectory value correct?
(I ask because it takes 24 hours for the data to update so getting it wrong costs a lot of time)
Turns out I was right. To filter on a directory and all subdirectories the settings should be
Predefined-Filter
Include Only
traffic to the subdirectories
that begin with
/dogs/
Not case sensitive

Resources