News for hackers. Stuff that matters.
Re:PowerShell is open sourced and is available on Linux by vasilia on Thursday August 18, 2016 @10:47PM (#12317671)
And how to delete files older 2 days? Get-Files / | select olderThan 2 | Delete-File ?

But it's not bash, it's coreutils

  find ./ -mtime +2 | xargs rm
Re:PowerShell is open sourced and is available on Linux by ygra on Friday August 19, 2016 @02:18AM (#12318258)

    Get-ChildItem -File | Where-Object LastWriteTime -lt (Get-Date).AddDays(-2) | Remove-Item
If you prefer shorter (and similarly obscure if you don't know the language):

    ls -file|? LastWriteTime -lt ((date)+'-2')|rm
I actually find PowerShell's version more readable, even if more verbose. But code is written only once and read a lot of times. I may not know what the +2 actually means with the -mtime argument. How would I change it to look for the age of two hours instead of days?
Re:PowerShell is open sourced and is available on Linux by vasilia on Friday August 19, 2016 @01:24PM (#12321704)
> I actually find PowerShell's version more readable, even if more verbose.

Sorry, I can't agree with you.

> I may not know what the +2 actually means with the -mtime argument. How would I change it to look for the age of two hours instead of days?

If you forget or doesn't know what is mtime, you can open man find. For less granularity than days use mmin.

Re:PowerShell is open sourced and is available on Linux by ksk on Friday August 19, 2016 @02:12PM (#12322077)
Just as an aside (and this probably applies to powershell as well), what if you have mapped folders from multiple servers into your file system and those servers are in different timezones? Something like

  /Mapped-Temp-folders/Server-Asia/temp
                      /Server-UK/temp
                      /Server-Japan/temp
I guess the script wouldn't work then if you wanted to clean out data older than 2 days, as per their timezone.
Re:PowerShell is open sourced and is available on Linux by useerup on Friday August 19, 2016 @11:00AM (#12320479)

    ls|? LastWriteTime -lt (date).AddDays(-2)|rm