Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Extract date and time part from filename Post 303033748 by RudiC on Thursday 11th of April 2019 05:46:21 AM
Old 04-11-2019
That's much clearer, thank you. How about (adding the new fields at the end, so we can print the format info as we go through the file)
Code:
awk '
FNR == 1        {FILENR++
                }

FILENR <= 2     {CNT++
                 CHFM[CNT] = $1
                 RGEX[CNT] = $2
                 DOTS[CNT] = $3
                 FMTS[CNT] = $4
                 FIDX[CNT] = FILENR
                 next
                }

                {printf "%s", $0
                 for (j=4; j<=5; j++)   {TMP = $j
                                         PTR = 0
                                         for (i=1; i<=CNT; i++) if (match (TMP, CHFM[i]))       {printf "|%s|%s|%s|%s|%s", PTR + RSTART, RLENGTH, CHFM[i], DOTS[i], FMTS[i]
                                                                                                 TMP = substr (TMP, RSTART+RLENGTH)
                                                                                                 PTR += RSTART + RLENGTH - 1
                                                                                                 TYP[j-3,FIDX[i]]++
                                                                                                }
                                        }
                 for (j=1; j<=2; j++) printf "|%s|%s", TYP[j,1], TYP[j,2]
                 print ""
                 split ("", TYP)
                }
'  FS=","  file[45] FS="|" OFS="|" file3

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

how to update date part with new increment date time

hi experts, my requirement is like this i need to develop a shell script to update date part with new incremental date time in file some 'X' which is kept at some server location incrementing every two hours.as i am new to this scripting i need support from u people,thanx in advance (1 Reply)
Discussion started by: amanmro
1 Replies

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv OTP_UFSC_20120530000000_prom.csv... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

7. Programming

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My code: if then set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator"\ "pam_account"; for i in 1 2 3 4 5 6 7 8;... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

8. Shell Programming and Scripting

Extract a part of a filename containing a particular word

Hi All, Thanks in Advance Shell Script or Perl Script I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv... (7 Replies)
Discussion started by: aealexanderraj
7 Replies

9. 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

10. UNIX for Beginners Questions & Answers

How to extract date and time from filename?

Hi, I'm totally new in sell script and working with a shell code. I want to extract the date and time from the filenames. The filenames are different but all of them begins with WI_ SCOPE_: WI_SCOPE_DATA_CHANGE_2017-09-12_15-30-40.txt WI_SCOPE_BACK_COMPLETE_QUEUE_2017-09-12_15-31-40.txt... (5 Replies)
Discussion started by: Home
5 Replies
gnutls_x509_crt_print(3)					      gnutls						  gnutls_x509_crt_print(3)

NAME
gnutls_x509_crt_print - Pretty print X.509 certificates SYNOPSIS
#include <gnutls/x509.h> int gnutls_x509_crt_print(gnutls_x509_crt_t cert, gnutls_certificate_print_formats_t format, gnutls_datum_t * out); ARGUMENTS
gnutls_x509_crt_t cert The structure to be printed gnutls_certificate_print_formats_t format Indicate the format to use gnutls_datum_t * out Newly allocated datum with zero terminated string. DESCRIPTION
This function will pretty print a X.509 certificate, suitable for display to a human. If the format is GNUTLS_CRT_PRINT_FULL then all fields of the certificate will be output, on multiple lines. The GNUTLS_CRT_PRINT_ONELINE format will generate one line with some selected fields, which is useful for logging purposes. The output out needs to be deallocate using gnutls_free(). RETURNS
On success, GNUTLS_E_SUCCESS is returned, otherwise a negative error value. REPORTING BUGS
Report bugs to <bug-gnutls@gnu.org>. GnuTLS home page: http://www.gnu.org/software/gnutls/ General help using GNU software: http://www.gnu.org/gethelp/ COPYRIGHT
Copyright (C) 2008 Free Software Foundation. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. SEE ALSO
The full documentation for gnutls is maintained as a Texinfo manual. If the info and gnutls programs are properly installed at your site, the command info gnutls should give you access to the complete manual. gnutls 2.8.6 gnutls_x509_crt_print(3)
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy