Sponsored Content
Top Forums Shell Programming and Scripting String substitution on find results inside exec/xargs Post 302196284 by myndcraft on Saturday 17th of May 2008 02:36:10 PM
Old 05-17-2008
Thanks era, works great! Time to spend some time with the sed docs though... I knew it could do it, but admittedly I'm not very familiar with it Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between xargs and exec

Hi, I have tried both the options in small dummy scripts, but somehow i can't differentiate between the two. find . -name H* -exec ls -l {} \; find . -name H* | xargs ls -l Both work the ditto way. Any help is appreciated. (19 Replies)
Discussion started by: vibhor_agarwali
19 Replies

2. Shell Programming and Scripting

MV files with xargs or -exec

Hi I need to move multiple (say 10 files) from one location to another location. My selection would be like this... ls -ltr *.arc | head ---> Need to move top 10 files with single command without iterating in loop. I know we can move files like this with find command but not sure if I can... (4 Replies)
Discussion started by: malaymaru
4 Replies

3. Shell Programming and Scripting

How to find a string inside files

Hi, I would like to know how to get a list of files that contain a specific string inside them. Thanks (12 Replies)
Discussion started by: yoavbe
12 Replies

4. Solaris

Piping results of 'ls' to 'find' using 'xargs'

I'm trying to get a count of all the files in a series of directories on a per directory basis. Directory structure is like (but with many more files): /dir1/subdir1/file1.txt /dir1/subdir1/file2.txt /dir1/subdir2/file1.txt /dir1/subdir2/file2.txt /dir2/subdir1/file1.txt... (4 Replies)
Discussion started by: MartynAbbott
4 Replies

5. UNIX for Dummies Questions & Answers

How to find a file with specific string inside it.

Hi , Is there any way i can find a file with specific word inside it. For example if i want to find a file which has some text written inside it. How would i form a command to search them? (3 Replies)
Discussion started by: pinga123
3 Replies

6. Shell Programming and Scripting

Display find results, and pipe to xargs

I have an overnight script which runs across a large directory to repair permissions and ownership. I also have this command output the list of files affected so that cron can email these as a log file. Previously I had the command in the form: find /path/to/files -not -user myname -print -exec... (4 Replies)
Discussion started by: mij
4 Replies

7. Programming

difference bewteen pipe, xargs, and exec

I have read several docs on these on the web and looked at examples. I can't figure out the difference. In some cases you use one or the other or you combine them. can someone help me understand this? (1 Reply)
Discussion started by: guessingo
1 Replies

8. Shell Programming and Scripting

xargs vs exec with find:

Hi All, i'm trying to create a tar of all the .txt files i find in my dir . I've used xargs to acheive this but i wanted to do this with exec and looks like it only archives the last file it finds . can some one advice what's wrong here : find . -type f -name "*.txt" -print0 | xargs -0... (9 Replies)
Discussion started by: Irishboy24
9 Replies

9. Shell Programming and Scripting

Difference b/w xargs and "-exec" in Find

Hi, What is the difference between the following commands find . -type f -exec grep 'abc' {} \; and find . -type f | xargs grep 'abc' Appreciate your help. (2 Replies)
Discussion started by: bobbygsk
2 Replies

10. Shell Programming and Scripting

Exec and xargs mvoe file to directory

Hello, I am trying to move all the file listed by below command to /tmp/testing directory find ./ -maxdepth 1 -type f -mtime +3 I tried using -exec and xargs - none of the combination is working? Please, help (3 Replies)
Discussion started by: saurabh84g
3 Replies
DateFormat(3pm) 					User Contributed Perl Documentation					   DateFormat(3pm)

NAME
Log::Log4perl::DateFormat - Log4perl advanced date formatter helper class SYNOPSIS
use Log::Log4perl::DateFormat; my $format = Log::Log4perl::DateFormat->new("HH:mm:ss,SSS"); # Simple time, resolution in seconds my $time = time(); print $format->format($time), " "; # => "17:02:39,000" # Advanced time, resultion in milliseconds use Time::HiRes; my ($secs, $msecs) = Time::HiRes::gettimeofday(); print $format->format($secs, $msecs), " "; # => "17:02:39,959" DESCRIPTION
"Log::Log4perl::DateFormat" is a low-level helper class for the advanced date formatting functions in "Log::Log4perl::Layout::PatternLayout". Unless you're writing your own Layout class like Log::Log4perl::Layout::PatternLayout, there's probably not much use for you to read this. "Log::Log4perl::DateFormat" is a formatter which allows dates to be formatted according to the log4j spec on http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html which allows the following placeholders to be recognized and processed: Symbol Meaning Presentation Example ------ ------- ------------ ------- G era designator (Text) AD y year (Number) 1996 M month in year (Text & Number) July & 07 d day in month (Number) 10 h hour in am/pm (1~12) (Number) 12 H hour in day (0~23) (Number) 0 m minute in hour (Number) 30 s second in minute (Number) 55 S millisecond (Number) 978 E day in week (Text) Tuesday D day in year (Number) 189 F day of week in month (Number) 2 (2nd Wed in July) w week in year (Number) 27 W week in month (Number) 2 a am/pm marker (Text) PM k hour in day (1~24) (Number) 24 K hour in am/pm (0~11) (Number) 0 z time zone (Text) Pacific Standard Time Z RFC 822 time zone (Text) -0800 ' escape for text (Delimiter) '' single quote (Literal) ' For example, if you want to format the current Unix time in "MM/dd HH:mm" format, all you have to do is this: use Log::Log4perl::DateFormat; my $format = Log::Log4perl::DateFormat->new("MM/dd HH:mm"); my $time = time(); print $format->format($time), " "; While the "new()" method is expensive, because it parses the format strings and sets up all kinds of structures behind the scenes, followup calls to "format()" are fast, because "DateFormat" will just call "localtime()" and "sprintf()" once to return the formatted date/time string. So, typically, you would initialize the formatter once and then reuse it over and over again to display all kinds of time values. Also, for your convenience, the following predefined formats are available, just as outlined in the log4j spec: Format Equivalent Example ABSOLUTE "HH:mm:ss,SSS" "15:49:37,459" DATE "dd MMM yyyy HH:mm:ss,SSS" "06 Nov 1994 15:49:37,459" ISO8601 "yyyy-MM-dd HH:mm:ss,SSS" "1999-11-27 15:49:37,459" APACHE "[EEE MMM dd HH:mm:ss yyyy]" "[Wed Mar 16 15:49:37 2005]" So, instead of passing Log::Log4perl::DateFormat->new("HH:mm:ss,SSS"); you could just as well say Log::Log4perl::DateFormat->new("ABSOLUTE"); and get the same result later on. Known Shortcomings The following placeholders are currently not recognized, unless someone (and that could be you :) implements them: F day of week in month w week in year W week in month k hour in day K hour in am/pm z timezone (but we got 'Z' for the numeric time zone value) Also, "Log::Log4perl::DateFormat" just knows about English week and month names, internationalization support has to be added. COPYRIGHT AND LICENSE
Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-07-21 DateFormat(3pm)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy