Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Help with grep to show date/time of file Post 303045374 by newbie_01 on Wednesday 18th of March 2020 04:53:12 PM
Old 03-18-2020
Help with grep to show date/time of file

Hi,


This is similar to what's been asked in the post below:

grep to show date/time of file the string was found in.


The solution sort of work / not work, the problem is if there is no match, then xargs does a full listing. That is if it found file/s that matches the search string and hence file exist, it does list the files but if it doesn't find a match it do a full listing instead Smilie


See example below:


Code:
$: ls -ltr
total 16
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file1
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file2
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file3
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file4
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file5
-rw-r-----   1 tester   omg            15 Mar 19 09:36 corrupt.txt
$: grep -il "bad" * | xargs ls -l
-rw-r-----   1 tester   dba           15 Mar 19 09:36 corrupt.txt
$: grep -il "corrupt" * | xargs ls -l
total 16
-rw-r-----   1 tester   omg            15 Mar 19 09:36 corrupt.txt
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file1
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file2
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file3
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file4
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file5
$: uname -a
SunOS [hostname] 5.11 11.3 sun4v sparc sun4v
$: cat corrupt.txt
BAD FILE FOUND

And just realized I can just actually just do ls -l but it gave me the same behaviour:


Code:
$: ls -l `grep -il "bad" *`
-rw-r-----   1 tester   omg            15 Mar 19 09:36 corrupt.txt
$: ls -l `grep -il "corrupt" *`
total 16
-rw-r-----   1 tester   omg            15 Mar 19 09:36 corrupt.txt
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file1
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file2
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file3
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file4
-rw-r-----   1 tester   omg            0 Mar 19 09:36 file5

I guess this is the expected behavior but kinda hoping it'll just do nothing if it doesn't find any or print something maybe instead? Any suggestion?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep time and date

Hi, I have a file which is a result of a script running every two minutes. What I wanted to do is to grep a specific date and time (hour and minute) from the file and then count the occurance of 201. I need to get the result of occurance of 201 every 5 minutes. What should I include in my... (8 Replies)
Discussion started by: ayhanne
8 Replies

2. Shell Programming and Scripting

Processing a log file based on date/time input and the date/time on the log file

Hi, I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies

3. Shell Programming and Scripting

grep to show date/time of file the string was found in.

I've seen several examples of grep showing the filename the string was found in, but what I really need is grep to show the file details in long format (like ls -l would). scenario is: grep mobile_number todays_files This will show me the string I'm after & which files they turn up in, but... (2 Replies)
Discussion started by: woodstock
2 Replies

4. Shell Programming and Scripting

Show date/time with tail|grep command

Hi, I have a log file without date/time, and I want that everytime tail|grep find something it displays the date/time and the line. I have tried something like this command but without any luck to display the date/time: tail -F catalina.out | sed "s/^/`date `/" | egrep ... (6 Replies)
Discussion started by: julugu
6 Replies

5. Shell Programming and Scripting

Grep the Content of a LOG File which has latest Date and Time

Hi All, Need a small help. I have a log file which keeps updating for every Minute with multiple number of lines. I just want to grep few properties which has latest Date and Time to it. How do i do it? I wanted to grep a property by name "Reloading cache with a maximum of" from the... (4 Replies)
Discussion started by: nvindraneel
4 Replies

6. UNIX Desktop Questions & Answers

grep a range of time & date

how can i grep a range? i have a text file with the following text: result.log.00:2012/01/02 12:00:07.422 LOG STARTED HERE N6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658, config=(alertThreshold=10,alertLevel=0,killThreshold=7200,coreThreshold=0,full=1), deltaTime=0,... (1 Reply)
Discussion started by: boaz733
1 Replies

7. Shell Programming and Scripting

Grep into a file + show following lines

Hi guys, This is probably very easy but I've no idea how to pull this out. Basically, I need to find errors into a very large logfile. When you grep the ID, the output is like this: +- Type: 799911 Code: Ret: 22728954 Mand: X Def: Des: UserDes: SeqNo: 2 +- Type: 799911 Code: Ret:... (5 Replies)
Discussion started by: Arkadia
5 Replies

8. UNIX for Dummies Questions & Answers

Does 'grep' update a file's access date/time?

I've got a job that finds and removes trace files based upon an access time of more than seven days (I've also tried a modify date). find TABC* -atime +7 -exec rm + find TABC* -mtime +7 -exec rm + Whether I use -atime or -mtime, the process seems to work sporadically. Sometimes it removes... (6 Replies)
Discussion started by: Scottie1954
6 Replies

9. UNIX for Advanced & Expert Users

Grep show file name once

I am using grep as follows grep --include \*.org -ir "sunspot" -C 3 ./astron_aphys/solarsy/sun/helioseism/localhs/fhankel/ This gives me the filename for each matched line. How can I change the command to print the file name only once rather than having the same file name repeated at... (2 Replies)
Discussion started by: kristinu
2 Replies

10. Shell Programming and Scripting

Show file name included time information

Hi all, I have many files included time information, some of them included time range by 30 minutes; 2007-12-27T110000.txt 2007-12-27T120000.txt 2007-12-27T130000.txt 2007-12-27T150000.txt 2007-12-27T153000.txt 2007-12-28T000000.txt 2007-12-28T003000.txt I only want to echo that... (5 Replies)
Discussion started by: jeo_fb
5 Replies
rmic(1) 						      General Commands Manual							   rmic(1)

NAME
rmic - Java RMI stub compiler SYNOPSIS
rmic [ options ] package-qualified-class-names DESCRIPTION
The rmic compiler generates stub and skeleton class files (JRMP protocol) and stub and tie class files (IIOP protocol) for remote objects. These class files are generated from compiled Java programming language classes that are remote object implementation classes. A remote implementation class is a class that implements the interface java.rmi.Remote. The classes named in the rmic command must be for classes that have been compiled successfully with the javac(1) command and be fully package-qualified. For example, running rmic on the class file name HelloImpl as shown here: rmic hello.HelloImpl creates the HelloImpl_Stub.class file in the hello subdirectory (named for the class's package). A skeleton for a remote object is a JRMP protocol server-side entity has a method that dispatches calls to the remote object implementa- tion. A tie for a remote object is a server-side entity similar to a skeleton, but which communicates with the client using the IIOP protocol. A stub is a proxy for a remote object that is responsible for forwarding method invocations on remote objects to the server where the actual remote object implementation resides. A client's reference to a remote object is actually a reference to a local stub. By default, rmic generates stub classes that use the 1.2 JRMP stub protocol version only, as if the -v1.2 option had been specified. (Note that the -vcompat option was the default in releases prior to 1.5.) Use the -iiop option to generate stub and tie classes for the IIOP pro- tocol. The stub implements only the remote interfaces, not local interfaces also implemented by the remote object. Because the stub implements exactly the same set of remote interfaces as the remote object, a client can use the Java language's built-in operators for casting and type-checking. For IIOP, the PortableRemoteObject.narrow method must be used. OPTIONS
-bootclasspath path Overrides location of bootstrap class files. -classpath path Specifies the path rmic uses to look up classes. Setting this option overrides the default or the CLASSPATH environment variable. Directories are separated by colons. Thus, the general format for path is: .:<your_path> For example: .:/usr/local/java/classes -d directory Specifies the root directory of the class hierarchy. You can use this option to specify a destination directory for the stub, skeleton, and tie files. For example, the command rmic -d /java/classes foo.MyClass would place the stub and skeleton classes derived from MyClass into the directory /java/classes/foo. If the -d option is not specified, the default behavior is as if "-d ." were specified: the package hierarchy of the target class is created in the current directory, and stub/tie/skeleton files are placed within it. (Note that in some previous versions of rmic, if -d was not specified, then the package hier- archy was not created, and all of the output files were placed directly in the current directory.) -extdirs path Overrides location of installed extensions. -g Enables generation of all debugging information, including local variables. By default, only line number information is gen- erated. -idl Causes rmic to generate OMG IDL for the classes specified and any classes referenced. IDL provides a purely declarative, programming language-independent way of specifying an object's API. The IDL is used as a specification for methods and data that can be written in and invoked from any language that provides CORBA bindings. This includes Java and C++ among others. When the -idl option is used, other options also include: -always or -alwaysgenerate Forces re-generation even when existing stubs/ties/IDL are newer than the input class. -factory Uses factory keyword in generated IDL. -idlModule fromJavaPackage[.class] toIDLModule Specifies IDLEntity package mapping. For example: -idlModule foo.bar my::real::idlmod. -idlFile fromJavaPackage[.class] toIDLFile Specifies IDLEntity file mapping. For example: -idlFile test.pkg.X TEST16.idl -iiop Causes rmic to generate IIOP stub and tie classes, rather than JRMP stub and skeleton classes. A stub class is a local proxy for a remote object and is used by clients to send calls to a server. Each remote interface requires a stub class, which implements that remote interface. A client's reference to a remote object is actually a reference to a stub. Tie classes are used on the server side to process incoming calls and dispatch the calls to the proper implementation class. Each implementation class requires a tie class. Invoking rmic with -iiop generates stubs and ties that conform to this naming convention: _<implementationName>_stub.class _<interfaceName>_tie.class When the -iiop option is used, other options also include: -always or -alwaysgenerate Forces re-generation even when existing stubs/ties/IDL are newer than the input class. -nolocalstubs Does not create stubs optimized for same-process clients and servers. -noValueMethods Must be used with the -idl option. Prevents addition of valuetype methods and initializers to emitted IDL. These methods and initializers are optional for valuetypes and are generated unless the -noValueMethods option is specified when using the -idl option. -poa Changes the inheritance from org.omg.CORBA_2_3.portable.ObjectImpl to org.omg.PortableServer.Servant. The PortableServer module for the Portable Object Adapter (POA) defines the native Servant type. In the Java program- ming language, the Servant type is mapped to the Java org.omg.PortableServer.Servant class. It server as the base class for all POA servant implementation and provides a number of methods that may be invoked by the application programmer, as well as methods which are invoked by the POA itself and may be overridden by the user to control aspects of servant behavior. Based on the OMG IDL to Java Language Mapping Specfication, CORBA V 2.3.1 ptc/00-01-08.pdf. -Joption Pass option to the Java virtual machine, where option is one of the options described on the man page for the java application launcher, java(1). For example, -J-Xms48m sets the startup memory to 48 megabytes. It is a common conven- tion for -J to pass options to the underlying virtual machine. -keepgenerated Retains the generated .java source files for the stub, skeleton, and/or tie classes and writes them to the same directory as the .class files -nowarn Turns off warnings. If used, the compiler does not print warnings. -vcompat Generates stub and skeleton classes compatible with both the 1.1 and 1.2 JRMP stub protocol versions. (This option was the default in releases prior to 1.5.) The generated stub classes will use the 1.1 stub protocol version when loaded in a JDK 1.1 virtual machine and will use the 1.2 stub protocol version when loaded into a 1.2 (or later) virtual machine. The gener- ated skeleton classes will support both 1.1 and 1.2 stub protocol versions. The generated classes are relatively large in order to support both modes of operation. -verbose Causes the compiler and linker to display messages about the classes being compiled and what class files being loaded. -v1.1 Creates stubs and skeletons for JDK 1.1 stub protocol version only. Note that this option is only useful for generating stub classes that are serialization-compatible with pre-existing, statically-deployed stub classes that were generated by the rmic tool from JDK 1.1 and that cannot be upgraded (and dynamic class loading is not being used). -v1.2 (default) Generates stub classes for the 1.2 JRMP stub protocol version only. No skeleton classes are generated with this option because skeleton classes are not used with the 1.2 stub protocol version. The generated stub classes will not work if they are loaded into a JDK 1.1 virtual machine. ENVIRONMENT VARIABLES
CLASSPATH Used to provide the system with a path to user-defined classes. Directories are separated by colons. For example, .:/usr/local/java/classes SEE ALSO
java(1), javac(1) CLASSPATH 23 June 2004 rmic(1)
All times are GMT -4. The time now is 10:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy