Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to extract date and time from filename? Post 303005544 by vgersh99 on Thursday 19th of October 2017 10:45:52 AM
Old 10-19-2017
to start with:
Code:
echo 'WI_SCOPE_DATA_CHANGE_2017-09-12_15-30-40.txt' | sed 's/.*_\([^_][^_]*_[^.][^.]*\).*/\1/'

or
Code:
echo 'WI_SCOPE_DATA_CHANGE_2017-09-12_15-30-40.txt' | awk -F'[_.]' '{print $(NF-2),$(NF-1)}' OFS=_


Last edited by vgersh99; 10-19-2017 at 12:11 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Renaming files to have date/time in filename

I have a program that will export my data to a single file, but it assigns a file name that is overridden every time I run the program. I need to change the file name to have a sequential number in the filename. How do I rename a file so that the filename contains the system date and time. I want... (5 Replies)
Discussion started by: wayneb
5 Replies

2. UNIX for Dummies Questions & Answers

Insert date/time within a filename

Hi Guys, I need to script the renaming of files as followins: files: firstjd secondjo thirdjv My script needs to insert the date/time infront of the last 2 characters of the filenames above, any ideas greatly received :) the letters before the last 2 characters could change, I'm only... (7 Replies)
Discussion started by: cooperman
7 Replies

3. UNIX for Advanced & Expert Users

find formatted filename with date time

Hi, I operate and use HF radars along the California coast for ocean surface currents. The devices use Mac OS as the control and logging software. The software generates thousands of files a week and while I've used PERL in the past to solve the problems of finding files I come to realize some... (6 Replies)
Discussion started by: dpath2o
6 Replies

4. UNIX for Dummies Questions & Answers

Adding Date & time stamps to filename

I need to edit the file name with date and time while writing the script. please help. (1 Reply)
Discussion started by: manish.s
1 Replies

5. Shell Programming and Scripting

Extract date from filename and create a new file

Hi, i have a filename CRED20102009.txt in a server 20102009 is the date of the file ddmmaaaa format the complete route is /dprod/informatica/Fuentes/CRED20102009.csv i want to extract the date to create a new file named Parameters.txt I need to create Parameters.txt with this... (6 Replies)
Discussion started by: angel1001
6 Replies

6. Shell Programming and Scripting

Extract date from filename and set timestamp

I have lots of files in this format: dvgrab-2003.06.29_15-30-24.mpg The numbers represents the date and time (YYYY.MM.DD_HH-MM-SS) How can I extract the dates from the filenames, and use the dates in the file timestamp? I guess this can be done by using "find", "sed" and "touch"? Can... (6 Replies)
Discussion started by: qwerty1234
6 Replies

7. Shell Programming and Scripting

append a filename with system date and time

Hi, There are similar kind of posts, but none seems like working for me. Please correct me if I'm wrong. I need append/rename file abc.txt with file processed date and time like abc_systemdatetimestamp.txt and move it to different folder. for example I have /source/data/abc.txt ... (1 Reply)
Discussion started by: amsn08
1 Replies

8. UNIX for Dummies Questions & Answers

Extract Date part from the filename

Hi All, I have incoming source files abcmmyy.txt I need to extract the mmyy part from the filename and pass that to a variable . I really appreciate your quick response on this. Thanks raj (7 Replies)
Discussion started by: rajeevm
7 Replies

9. Shell Programming and Scripting

Validate date and time in filename by awk

hi i want to validate the date and time in filename filename : mohan.moh.ccyymmdd.ccyymmdd.hhmmss.txt mohan_moh.20151222.20151222.122442.txt i want code that check that date given in filename 20151222 in this format ccyymmdd else it mark file is not valid used in my OS detail is AIX 6... (12 Replies)
Discussion started by: MOHANP12
12 Replies

10. UNIX for Beginners Questions & Answers

Extract date and time part from filename

Hi, I am facing one scenario in which I need to extract exact position of date and time from the name of the files. For example, Below is the record in which I need to extract position of YYYYMMDD,HHMISS and YYMMDD. Date and time variables can come more than once. I need to use these position... (13 Replies)
Discussion started by: Prathmesh
13 Replies
MU-EXTRACT(1)                                                 General Commands Manual                                                MU-EXTRACT(1)

NAME
mu_extract - display and save message parts (attachments), and open them with other tools. SYNOPSIS
mu extract [options] <file> mu extract [options] <file> <pattern> DESCRIPTION
mu extact is the mu sub-command for extracting MIME-parts (e.g., attachments) from mail messages. It works on message files, and does not require the message to be indexed in the database. For attachments, the file name used when saving it, is the name of the attachment in the message. If there is no such name, or when saving non-attachment MIME-parts, a name is derived from the message-id of the message. If you specify a pattern (a case-insensitive regular expression) as the second argument, all attachments with filenames matching that pat- tern will be extracted. The regular expressions are Perl-compatible (as per the PCRE-library). Without any options, mu extract simply outputs the list of leaf MIME-parts in the message. Only 'leaf' MIME-parts (including RFC822 attach- ments) are considered, multipart/* etc. are ignored. OPTIONS
-a, --save-attachments save all MIME-parts that look like attachments. --save-all save all non-multipart MIME-parts. --parts=<parts> only consider the following numbered parts (comma-separated list).The numbers for the parts can be seen from running mu extract without any options but only the message file. --target-dir=<dir> save the parts in the target directory rather than the current working directory. --overwrite overwrite existing files with the same name; by default overwriting is not allowed. --play Try to 'play' (open) the attachment with the default application for the particular file type. On MacOS, this uses the open program, on other platforms is uses xdg-open. You can choose a different program by setting the MU_PLAY_PROGRAM environment variable. EXAMPLES
To display information about all the MIME-parts in a message file: $ mu extract msgfile To extract MIME-part 3 and 4 from this message, overwriting existing files with the same name: $ mu extract --parts=3,4 --overwrite msgfile To extract all files ending in '.jpg' (case-insensitive): $ mu extract msgfile '.*.jpg' To extract an mp3-file, and play it in the the default mp3-playing application. $ mu extract --play msgfile 'whoopsididitagain.mp3' BUGS
Please report bugs if you find them: http://code.google.com/p/mu0/issues/list AUTHOR
Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> SEE ALSO
mu(1) User Manuals February 2012 MU-EXTRACT(1)
All times are GMT -4. The time now is 09:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy