Operating System - HP-UX
1748219 Members
4244 Online
108759 Solutions
New Discussion юеВ

Re: Help in automatically removing lines.

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: Help in automatically removing lines.

>Siddhartha: This will find the line number where pattern #new lines is

And will also read the whole file, then the first part again.
Soul_1
Respected Contributor

Re: Help in automatically removing lines.

Hi,

I want to print the previous day date.
Please let me know how can i achieve it.


Thanks in advance
Horia Chirculescu
Honored Contributor

Re: Help in automatically removing lines.

Hello,

echo `(export TZ=XYZ+24; date "+%d/%m/%y")`

Horia.
Best regards from Romania,
Horia.
Soul_1
Respected Contributor

Re: Help in automatically removing lines.

Hi Horia,

Thanks a lot for your response

can you just brief what this command will do ?

Also what will happen at the starting of month. say jan 1. In that case will it display the last year an last month date ?

Regards,
Horia Chirculescu
Honored Contributor

Re: Help in automatically removing lines.

Hello.

>Also what will happen at the starting of month. say jan 1. In that case will it display the last year an last month date ?

Yes, it will work. Will work also on March, 1 showing February 28/29 and so...

Horia.
Best regards from Romania,
Horia.
Soul_1
Respected Contributor

Re: Help in automatically removing lines.

Hi,
I want to customize the year part of the o/p.

rt now its showing as 07/03/10 , iwant it in 07/03/2010.

Regards
Horia Chirculescu
Honored Contributor

Re: Help in automatically removing lines.

>now its showing as 07/03/10 , iwant it in 07/03/2010.

Just change %y with %Y

man date should help.

Horia.
Best regards from Romania,
Horia.
James R. Ferguson
Acclaimed Contributor

Re: Help in automatically removing lines.

Hi:

> I want to customize the year part of the o/p...its showing as 07/03/10 , i want it in 07/03/2010

# perl -MPOSIX -le 'print strftime "%02m/%02d/%Y",localtime(time-(60*60*24))'

...will give you yesterday's date correctly, crossing year boundaries as necessary.

You can change the format of the output just like you would using a simple 'date' command format.

Do *not* be fooled by trying to manipulate your 'TZ' variable by adding or subtracting 24-hours. This works correctly only for UTC (GMT) timezones. Use Perl;

Regards!

...JRF...

Horia Chirculescu
Honored Contributor

Re: Help in automatically removing lines.

James: > This works correctly only for UTC (GMT) timezones


Can you please explain this?


Horia.
Best regards from Romania,
Horia.
Dennis Handly
Acclaimed Contributor

Re: Help in automatically removing lines.

>Horia: Can you please explain this?

The code in libc only expects to have valid timezones. These are UTC +/- 12 hours.

What you did was:
$ TZ=XYZ+24 date "+%d/%m/%y %Z"
08/03/10 XYZ

This converts to UTC time and adds 24 hours. What if there was a DST transition and you skip or lose a day?