12-01-2008
Not working - any one help please
Can any one please provide the command,
the below command works wrong,
sed 's/.*getdate(),\(.*\),\(.*\),.*/\2/' < file
my txt file:
------------------------------------------
values('SGAV01204','retention_cd','retention_cd','C','EQUALS','N',-999, NULL,NULL,'N','N',NULL, NULL,'SYSTEM',getdate(),'0','D','0','S','N',0,'N','N','00',NULL1,NULL2,'N',NULL3,NULL4,NULL)
------------------------------------------
output for the above command:
by using above sed command (sed 's/.*getdate(),\(.*\),\(.*\),.*/\2/' file) i am getting below O/P:
O/P:
------------------------------------------
values('SGAV01204','retention_cd','retention_cd','C','EQUALS','N',-999, NULL,NULL,'N','N',NULL, NULL,'SYSTEM', NULL4
------------------------------------------
but expected output is just :
------------------------------------------
'D'
------------------------------------------
(2nd word after getdate() word)
Instead it printing from back side 2nd word also the first line.
can any one please give the sed command which provide the exact O/P i needed(only the second word after getdate() and NOT the first line). I dont need the first line also.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
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
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
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
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
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
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
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
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
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) 1 GETDATE(3)
getdate - Get date/time information
SYNOPSIS
array getdate ([int $timestamp = time()])
DESCRIPTION
Returns an associative array containing the date information of the $timestamp, or the current local time if no $timestamp is given.
PARAMETERS
o $timestamp
- The optional $timestamp parameter is an integer Unix timestamp that defaults to the current local time if a $timestamp is not
given. In other words, it defaults to the value of time(3).
RETURN VALUES
Returns an associative array of information related to the $timestamp. Elements from the returned associative array are as follows:
Key elements of the returned associative array
+----------+--------------------------------------+---+
| Key | | |
| | | |
| | Description | |
| | | |
| | Example returned values | |
| | | |
+----------+--------------------------------------+---+
| | | |
|"seconds" | | |
| | | |
| | Numeric representation of seconds | |
| | | |
| | | |
| | 0 to 59 | |
| | | |
| | | |
|"minutes" | | |
| | | |
| | Numeric representation of minutes | |
| | | |
| | | |
| | 0 to 59 | |
| | | |
| | | |
| "hours" | | |
| | | |
| | Numeric representation of hours | |
| | | |
| | | |
| | 0 to 23 | |
| | | |
| | | |
| "mday" | | |
| | | |
| | Numeric representation of the day of | |
| | the month | |
| | | |
| | | |
| | 1 to 31 | |
| | | |
| | | |
| "wday" | | |
| | | |
| | Numeric representation of the day of | |
| | the week | |
| | | |
| | | |
| | 0 (for Sunday) through 6 (for Satur- | |
| | day) | |
| | | |
| | | |
| "mon" | | |
| | | |
| | Numeric representation of a month | |
| | | |
| | | |
| | 1 through 12 | |
| | | |
| | | |
| "year" | | |
| | | |
| | A full numeric representation of a | |
| | year, 4 digits | |
| | | |
| | Examples: 1999 or 2003 | |
| | | |
| | | |
| "yday" | | |
| | | |
| | Numeric representation of the day of | |
| | the year | |
| | | |
| | | |
| | 0 through 365 | |
| | | |
| | | |
|"weekday" | | |
| | | |
| | A full textual representation of the | |
| | day of the week | |
| | | |
| | | |
| | Sunday through Saturday | |
| | | |
| | | |
| "month" | | |
| | | |
| | A full textual representation of a | |
| | month, such as January or March | |
| | | |
| | | |
| | January through December | |
| | | |
| | | |
| 0 | | |
| | | |
| | Seconds since the Unix Epoch, simi- | |
| | lar to the values returned by | |
| | time(3) and used by date(3). | |
| | | |
| | System Dependent, typically | |
| | -2147483648 through 2147483647. | |
| | | |
+----------+--------------------------------------+---+
EXAMPLES
Example #1
getdate(3) example
<?php
$today = getdate();
print_r($today);
?>
The above example will output something similar to:
Array
(
[seconds] => 40
[minutes] => 58
[hours] => 21
[mday] => 17
[wday] => 2
[mon] => 6
[year] => 2003
[yday] => 167
[weekday] => Tuesday
[month] => June
[0] => 1055901520
)
SEE ALSO
date(3), idate(3), localtime(3), time(3), setlocale(3).
PHP Documentation Group GETDATE(3)