Sponsored Content
Full Discussion: Extract string from filename
Top Forums Shell Programming and Scripting Extract string from filename Post 302776393 by Jotne on Wednesday 6th of March 2013 08:41:41 AM
Old 03-06-2013
With awk
Code:
echo "FILENAME_STRUT_01032013_XXXXXXX.TXT" | awk -F_ '{print $3}'
01032013

Use code tags

Last edited by joeyg; 03-06-2013 at 10:21 AM.. Reason: corrected spelling
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract only filename

Hi, I want to display only the file names of the ls command with a delimiter of comma. For example:- ls /etc/dir/N* gives the following output /etc/dir/N1 /etc/dir/N2 /etc/dir/N3 I want the output as N1,N2,N3,-->Here i need the final comma also. Also, here /etc/dir is being... (2 Replies)
Discussion started by: dnat
2 Replies

2. Shell Programming and Scripting

extract string portion from filename using sed

Hi All, I posted something similar before but I now have a another problem. I have filenames as below TOP_TABIN240_20090323.200903231830 TOP_TABIN235_1_20090323.200903231830 i need to extract the dates as in bold. Using bash v 3.xx Im trying to using the print sed command but... (11 Replies)
Discussion started by: santam
11 Replies

3. Shell Programming and Scripting

How to extract timestamp from the filename?

Hi., My file name is of the format: name_abc_20100531_142528.txt where., my timestamp is of the format: yyyymmdd_hhmmss How to extract the date strring and time string into seperate variables in the shell script, after reading the file as the input? I want to get the variables... (9 Replies)
Discussion started by: av_vinay
9 Replies

4. Shell Programming and Scripting

loop and extract matching filename

i am unable to exact matching filename in the loop. Filename.in file contains Customer_Product_ Information_Customer_Product_ sale_Product_ /home_dir contains files CUST_INFO_990090_1111.csv "1","Customer Product Detail","1000","salary" "1","Information Customer Product... (2 Replies)
Discussion started by: onesuri
2 Replies

5. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

6. Shell Programming and Scripting

extract every filename containing certain string in a directory and do some commend per file

Hi, Here is my question: suppose I have files like 1990_8xdaily_atmos.nc 1991_8xdaily_atmos.nc 1992_8xdaily_atmos.nc 1993_8xdaily_atmos.nc 1990_daily_atmos.nc 1991_daily_atmos.nc 1992_daily_atmos.nc 1993_daily_atmos.nc 1990_month_atmos.nc 1991_month_atmos.nc 1992_month_atmos.nc... (1 Reply)
Discussion started by: 1988PF
1 Replies

7. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

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

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

10. Shell Programming and Scripting

Extract filename from a given string

I want to extract the filename from a string. This is how I have the rawdata ina file /home/sid/ftp/testing/abc.txt /home/sid/ftp/tested/testing/def.txt /home/sid/sftp/date/misc/hij.txt i want a script which would provide me an output like this Directory ... (10 Replies)
Discussion started by: sidnow
10 Replies
Locale::Maketext::Extract::Plugin::Base(3)		User Contributed Perl Documentation		Locale::Maketext::Extract::Plugin::Base(3)

NAME
Locale::Maketext::Extract::Plugin::Base - Base module for format parser plugins SYNOPSIS
package My::Parser::Plugin; use base qw(Locale::Maketext::Extract::Plugin::Base); sub file_types { return [qw( ext ext2 )] } sub extract { my $self = shift; local $_ = shift; my $line = 1; while (my $found = $self->routine_to_extract_strings) { $self->add_entry($str,[$filename,$line,$vars]) } return; } DESCRIPTION
All format parser plugins in Locale::Maketext::Extract inherit from Locale::Maketext::Extract::Plugin::Base. If you want to write your own custom parser plugin, you will need to inherit from this module, and provide "file_types()" and "extract()" methods, as shown above. METHODS
new() $plugin = My::Parser->new( @file_types # Optionally specify a list of recognised file types ) add_entry() $plugin->add_entry($str,$line,$vars) "entries()" $entries = $plugin->entries; "clear()" $plugin->clear Clears all stored entries. file_types() @default_file_types = $plugin->file_types Returns a list of recognised file types that your module knows how to parse. Each file type can be one of: o A plain string 'pl' => base filename is matched against qr/.pl$/ '*' => all files are accepted o A regex qr/.tt2?./ => base filename is matched against this regex o A codref sub {} => this codref is called as $coderef->($base_filename,$path_to_file) It should return true or false extract() $plugin->extract($filecontents); extract() is the method that will be called to process the contents of the current file. When it finds a string that should be extracted, it should call $self->add_entry($string,$line,$vars]) where $vars refers to any arguments that are being passed to the localise function. For instance: l("You found [quant,_1,file,files]",files_found) string: "You found [quant,_1,file,files]" vars : (files_found) IMPORTANT: a single plugin instance is used for all files, so if you plan on storing state information in the $plugin object, this should be cleared out at the beginning of "extract()" known_file_type() if ($plugin->known_file_type($filename_with_path)) { .... } Determines whether the current file should be handled by this parser, based either on the list of file_types specified when this object was created, or the default file_types specified in the module. SEE ALSO
xgettext.pl for extracting translatable strings from common template systems and perl source files. Locale::Maketext::Lexicon Locale::Maketext::Extract::Plugin::Perl Locale::Maketext::Extract::Plugin::PPI Locale::Maketext::Extract::Plugin::TT2 Locale::Maketext::Extract::Plugin::YAML Locale::Maketext::Extract::Plugin::FormFu Locale::Maketext::Extract::Plugin::Mason Locale::Maketext::Extract::Plugin::TextTemplate Locale::Maketext::Extract::Plugin::Generic AUTHORS
Clinton Gormley [DRTECH] <clinton@traveljury.com> COPYRIGHT
Copyright 2002-2008 by Audrey Tang <cpan@audreyt.org>. This software is released under the MIT license cited below. The "MIT" License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. perl v5.16.2 2011-03-02 Locale::Maketext::Extract::Plugin::Base(3)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy