Linux/Unix: How to manipulate or change the last modified/accessed time of a file using touch command?
Assume there’s a file @ /home/user/testmsg.txt If you want to change the file timestamp to 09/20/2011 08:30 using touch command, here’s how you can do it: From Wikipedia, touch is a standard Unix program used to change a file‘s access and modification timestamps. It is also used to create a new empty file. Related articles […]
Getting started with Java’s ProcessBuilder: A simple utility class to interact with Linux from Java program
JDK 5.0 adds a new way of executing a command in a separate process, through a class called ProcessBuilder. You can find ProcessBuilder in the java.lang package (like Runtime and Process). According to the docs, This class is used to create operating system processes.Each ProcessBuilder instance manages a collection of process attributes. The start() method […]
While I was writing a shell script, I needed the last modified time of a particular file before doing something, and here’s what I used: stat -c ‘%Y’ /root/directory/file.txt This command will give you the last modified time of a file in seconds (since Epoch).