Sponsored Content
Top Forums Shell Programming and Scripting Extract a part of a filename containing a particular word Post 302692313 by Subbeh on Monday 27th of August 2012 11:39:12 AM
Old 08-27-2012
Or take the first 24 characters of the filename:

Code:
prefix=$(ls|head -1| sed 's/^\(.\{24\}\).*/\1/')
for file in acc faf prom subs ; do
        [ -e ${prefix}${file}.csv ] || touch ${prefix}${file}.csv
done

This User Gave Thanks to Subbeh For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

part of a filename

Hi, I need to extract only a part of the filenames of some files. The files are named this way : .tap_profile_SIT02 I want the "SIT02" part, which is not the same for each file. I was able to get what I want with bash, but not with ksh. Here is the command I used in bash : find... (8 Replies)
Discussion started by: flame_eagle
8 Replies

2. Shell Programming and Scripting

Extract Part of a "Word", using AWK or SED????

I have been lurking on this forum for some time now and appreciate Everyone's help. I need to find a way to get the SystemID from this XML file. The file is much larger than just this one line but I can grep and get this line Printed. But really just need the "systemid". <test123: prefintem... (9 Replies)
Discussion started by: elbombillo
9 Replies

3. Shell Programming and Scripting

grep part of word or Another word from a string

Hi all, FileOne family balance >>>>> 0 0 0 0 java.io.FileNotFoundException: Settings.xml (No such file or directory) at java.io.FileInputStream.open(Native Method) .. .... ..... ..... java.lang.NullPointerException ... ..... ...... Stacktrace: at... (2 Replies)
Discussion started by: linuxadmin
2 Replies

4. Shell Programming and Scripting

extract whole thing in word, leaving behind last word. - perl

Hi, i've a string /u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD/TESi T_11_HD_120/hd-12 i need to get string, like /u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD the words from HD should get deleted, i need only a string till HD, i dont want to use any built in... (4 Replies)
Discussion started by: asak
4 Replies

5. Shell Programming and Scripting

Getting part of a filename

Hi All, I'm trying to get part of a filename and my skill with regular expression are lacking. I know I need to use SED but have no idea how to use it. I'm hoping that someone can help me out. The file names would be: prefix<partwewant>suffix.extension the prefix and suffix are always 3... (4 Replies)
Discussion started by: imonkey
4 Replies

6. Shell Programming and Scripting

Extract part of word from XML

Hi All, Can Someone help me in capturing a word from xml Using sed or awk or any other way in unix. i have file abc.xml like this <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> - <NREC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <HEADER> <SOURCE>MAIL</SOURCE>... (5 Replies)
Discussion started by: naveenkumarc
5 Replies

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

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

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

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
Agent::Channel::Handle(3pm)				User Contributed Perl Documentation			       Agent::Channel::Handle(3pm)

NAME
Log::Agent::Channel::Handle - I/O handle logging channel for Log::Agent SYNOPSIS
require Log::Agent::Channel::Handle; my $driver = Log::Agent::Channel::Handle->make( -prefix => "prefix", -stampfmt => "own", -showpid => 1, -handle => *FILE, ); DESCRIPTION
The handle channel performs logging to an already opened I/O handle, along with the necessary prefixing and stamping of the messages. The creation routine make() takes the following arguments: "-handle" => handle Specifies the I/O handle to use. It can be given as a GLOB reference, such as "*FILE", or as an "IO::Handle" object. NOTE: Auto-flushing is not enabled on the handle. Even when the channel is closed, the handle is left as-is: we simply stop sending log messages to it. "-no_newline" => flag When set to true, never append any " " (on Unix) or " " (on Windows) to log messages. Internally, Log::Agent relies on the channel to delimit logged lines appropriately, so this flag is not used. However, it might be useful for "Log::Agent::Logger" users. Default is false, meaning newline markers are systematically appended. "-no_prefixing" => flag When set to true, disable the prefixing logic entirely, i.e. the following options are ignored completely: "-prefix", "-showpid", "-no_ucfirst", "-stampfmt". Default is false. "-no_ucfirst" => flag When set to true, don't upper-case the first letter of the log message entry when there's no prefix inserted before the logged line. When there is a prefix, a ":" character follows, and therefore the leading letter of the message should not be upper-cased anyway. Default is false, meaning uppercasing is performed. "-prefix" => prefix The application prefix string to prepend to messages. "-showpid" => flag If set to true, the PID of the process will be appended within square brackets after the prefix, to all messages. Default is false. "-stampfmt" => (name | CODE) Specifies the time stamp format to use. By default, my "own" format is used. See Log::Agent::Stamping for a description of the available format names. You may also specify a CODE ref: that routine will be called every time we need to compute a time stamp. It should not expect any parameter, and should return a string. CAVEAT
Beware of chdir(). If your program uses chdir(), you should always specify logfiles by using absolute paths, otherwise you run the risk of having your relative paths become invalid: there is no anchoring done at the time you specify them. This is especially true when configured for rotation, since the logfiles are recreated as needed and you might end up with many logfiles scattered throughout all the directories you chdir()ed to. AUTHOR
Raphael Manfredi <Raphael_Manfredi@pobox.com> SEE ALSO
Log::Agent::Logger(3), Log::Agent::Channel(3). perl v5.10.0 2002-03-09 Agent::Channel::Handle(3pm)
All times are GMT -4. The time now is 05:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy