Print all lines after a string

My file has the following contents...

User:SYS,O/SUser:oracle,Process:10813484,Machine:host123.xxx.xxx.xxxxxxx.com.au,Program:sqlplus@host123.xxx.xxx.xxxxxxx.com.au(TNSV1-V,LogonTime:24-JUL-2014 
15:04

I would like to print all character appearing after the string LogonTime:

My output shoud be...

24-JUL-2014 15:04

Thanks

Please use

```text
 and 
```

tags around any data or programs.

Try this:

sed 's/^.*LogonTime://' infile

The query gives me the following output...

sed 's/^.*LogonTime:*//' sample.log
User:SYS,O/SUser:oracle,Process:10813484,Machine:host123.xxx.xxx.xxxxxxx.com.au
24-JUL-2014
15:04
sed 's/.*LogonTime:\(.*\)/\1/' file
awk -F 'LogonTime:' 'NF>1{print $2}' file

Or try:

awk -F"LogonTime:" '{print $2}' infile

[/FONT][/COLOR]

If you would have used CODE tags as required by forum rules, people who looked at your post (before it was edited by an administrator), might have realized that your sample input was two lines instead of one, and might have known that the 1st line in your sample input ended with a space character just before the newline line terminator.

This seems to do what you have requested:

awk '
f {	printf("%s", $0)
	next
}
{	if(f = sub(/.*LogonTime:/, ""))
		printf("%s", $0)
}
END {	if(f)
		print ""
}' file
1 Like