Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to grep the word and display only the second word from it Post 302269335 by kalimat on Wednesday 17th of December 2008 12:01:29 PM
Old 12-17-2008
if a have a line like this: wtmp begins Fri Nov 28 .....
what can i do that it displays only the first word of line, or the 3rd?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep a word and display its column

Hi, I need idea about this, say I have this line: 05 21 * * 0,6 /user/clean.desktop.sh > /tmp/desktop_rpt 2>&1 I would need to grep the word desktop and display the /user/clean.desktop.sh and not the whole line. And if I have some more lines say, 05 21 * * 0,6 /user/clean.desktop.sh >... (1 Reply)
Discussion started by: Orbix
1 Replies

2. UNIX for Dummies Questions & Answers

how to grep for a word and display only the word

Hi, When we "grep" for a word in a file, it returns the lines containing the word that we searched for. Is there a way to display only the words and not the entire line containing them. Thanks Ananth (6 Replies)
Discussion started by: ananthmm
6 Replies

3. Shell Programming and Scripting

How to Grep for particular word and display..

Hi Guru's.... I've one log file in all my systems which writes the backup information.. I'have written a command like this: ssh -l ora${sid} ${primaryhost} "tail -50 /oracle/$ORACLE_SID/newbackup/END_BACKUP.log" |grep 'insert' |tail -1| awk '{print $7}' We have nearly 50 systems in our... (2 Replies)
Discussion started by: suri.tyson
2 Replies

4. Shell Programming and Scripting

grep display word only

Folks, is it possible to display only words with grep (or any built-in ultility)? I have more than 1 pattern to search, say apple & orange The text goes like this: So I need to display all the words starting with apple or orange The output should be: Any idea? (7 Replies)
Discussion started by: bsddaemon
7 Replies

5. Shell Programming and Scripting

Grep out specific word and only that word

ok, so this is proving to be kind of difficult even though it should not be. say for instance I want to grep out ONLY the word fkafal from the below output, how do I do it? echo ajfjf fjfjf iafjga fkafal foeref afoafahfia | grep -w "fkafal" If i run the above command, i get back all the... (4 Replies)
Discussion started by: SkySmart
4 Replies

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

7. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

8. Shell Programming and Scripting

Grep word after last occurance of string and display next few lines

Hi, I wanted to grep string "ERROR" and "WORNING" after last occurrence of String "Starting" only and wanted to display two lines after searched ERROR and WORNING string and one line before. I have following cronjob log file "errorlog" file and I have written the code for same in Unix as below... (17 Replies)
Discussion started by: nes
17 Replies

9. Shell Programming and Scripting

Grep for a word or word with underscore

I have a file "test" with following contents: cat test abc abcd_efg abc_abc I want to only grep for abc or abc_ without getting other results, how do I achieve this? If I use grep -w abc test option I get only abc and not abc_. If I use egrep "abc|abc_" test its still printing... (3 Replies)
Discussion started by: ctrld
3 Replies

10. Shell Programming and Scripting

How to grep for a word and display last transection?

Hi, When we "grep" for a word in a file, it returns the last lines containing the word that we searched for. Is there a way to display last line to grep. Thanks Ex log. Ex. logname.log 2015-07-29 06:43:07.023|BETA |2015-07-29... (5 Replies)
Discussion started by: ooilinlove
5 Replies
getdate(3)						     Library Functions Manual							getdate(3)

NAME
getdate, getdate_r - Convert formatted string into time/date structure LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include<time.h> struct tm *getdate( const char *string); The following function declarations do not conform to current standards and are supported only for backward compatibility: #include<time.h> struct tm *getdate( char *string); struct tm *getdate_r( char *string, struct tm *ptr, int *getdate_err); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: getdate(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the user-definable date and/or time specifications. Points to a time structure. Points to the local getdate_err. DESCRIPTION
The getdate() function fills a struct tm based on a combination of the supplied string argument and the template file of allowable formats for that argument. The template file is obtained from the DATEMSK environment variable. As the pathname is passed to fopen(), it must either be a fully qual- ified pathname, or must refer to a file in the current directory whenever getdate() is called. The template file is read line by line, and each line is parsed against the argument string in an attempt to make a match. All comparisons are made without regard to case. A matching template line will result in a valid struct tm being filled in and returned. In the event that no match is found, an error is returned in getdate_err. Each line of the template file provides a possible format to match against the input string. The format is specified by combining special time/date specifier characters preceded by % to indicate the particular time/date functions desired. The external variable or macro getdate_err is used by getdate() to return error values. The following field descriptors are supported: Literal % character Abbreviated weekday name Full weekday name Abbreviated month name Full month name Locale's appropriate date and time representation Day of month: 1 through 31, with optional leading zero Date string formatted as %m/%d/%y Same as %d. Abbreviated month name **Same as %b.???????????? Hour: 00 through 23 Hour: 01 through 12 Month number: 01 through 12 Minute: 00 through 59 Literal newline character Locale's equivalent to AM or PM string Locale's appropriate representation of time (formatted as %I:%M:%S %p in the POSIX locale). Time formatted as %H:%M Seconds: 00 through 61. Leap seconds, through the use of algo- rithms, are allowed but are not predictable. Whitespace up through literal tab Locale's appropriate representation of time in AM and PM notation (%H:%M:%S in the POSIX locale). Weekday number: 0 (Sunday) through 6 (Saturday) Date formatted as specified by locale Time for- matted as specified by locale Year (excluding century). When a century is not otherwise specified (for example, with %C), values in the range 69-99 refer to years in the twentieth century (1969 to 1999, inclusive); values in the range 00-68 refer to years in the twenty-first century (2000 to 2068, inclusive). Year (including century) as ccyy (for example, 1996) Time zone name or no characters if no time zone exists. If the time zone supplied by %Z is not the time zone that getdate() expects, an invalid input specification error will result. The getdate() function calculates an expected time zone based on information supplied to the function (such as the hour, day, and month). If the string parameter specifies the date and time incompletely, the following rules apply: If %Z is being scanned, getdate() initializes the broken-down time to be the current time in the scanned time zone. Otherwise, it initializes the broken-down time based on the current local time as if localtime() had been called. If a year is specified alone, the remainder of the date defaults to January 1. If a month is specified without a day of the month or day of the week, the next month matching that month is used, starting with the current month. The year advances if the matching month is beyond the current year. The day of the month defaults to the 1st. If a day of the week is specified, the next date matching that day is used, starting with the current day. The month advances if the matching day is beyond the end of the current month. The year may advance similarly. In cases 2, 3 and 4, the time of day is not altered unless it is explicitly specified. If time alone is specified, the date defaults to today (the current day), unless the time specified is earlier than now (the current time), in which case the date defaults to tomorrow. RETURN VALUES
Upon successful completion, the getdate() function returns a pointer to a struct tm. Otherwise, it returns a null pointer and the external variable getdate_err is set to indicate the error. Upon successful completion, the getdate_r function returns pointer struct tm. Otherwise, NULL is returned and the int value pointed to by the getdate_err pointer is set to indicate the error. ERRORS
If an error is detected, getdate() will return NULL and set the error number in getdate_err. The possible error numbers and their meanings are listed below. The DATEMSK environment variable is null or undefined. The template file cannot be opened for reading. Failed to get file status information. The template file is not a regular file. An I/O error occurred while reading the template file. Memory alloca- tion failed (not enough memory available). The template does not have a line that matches the input. Invalid input specification (for example, February 31). A time is specified that cannot be represented in a time_t (representing the time in seconds since 00:00:00 UTC, January 1, 1970). APPLICATION USAGE
Applications should use %Y (4-digit years) instead of %y (2-digit years). RELATED INFORMATION
Functions: ctime(3), ctype(3), setlocale(3), strftime(3) Standards: standards(5) delim off getdate(3)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy